Image: Conversion: Convert to Image
Convert data matrix to grayscale image
1. m2img bits:=16;
2. m2img min:=0.5 max:=1;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input Matrix | im |
Input MatrixObject |
|
Specifies the numeric matrix object to be converted. By default, it is the active matrix object. |
Output Image | om |
Output MatrixObject |
|
Specifies the output image. By default, a new image will be created and used for output. See the syntax here. |
Bits/Pixel | bits |
Input int |
|
Specifies the bits per pixel for the output image. The default value is 8. |
Black Value | min |
Input double |
|
Specifies the value to be mapped to the black color. The default input is <auto>, which corresponds to the minimum cell value of the input matrix object. |
White Value | max |
Input double |
|
Specifies the value to be mapped to the white color. The default input is <auto>, which corresponds to the maximum cell value of the input matrix object. |
This X-Function converts a numeric matrix object to a grayscale image with mapping. The values in the matrix are mapped to [0, ], where bpp is the specified bits per pixel. The matrix values that are not greater than the specified Black Value will be mapped to 0, which represent the black color; the matrix values that are not less than the specified White Value will be mapped to
, which represent the white color; the other values are mapped to the output range linearly.
Note that the grayscale levels in the output image must be integers. Thus, rounding might be performed after mapping, causing some details to be dropped.
In this example, we create a numeric matrix and use the m2img function to convert it to an 8-bit image:
Let x be a cell value of the input matrix and f(x) be the gray level of the image pixel that correspond to the cell. The linear mapping of x onto f(x) can be expressed as follows:
where bpp is the bits per pixel of the output image, BlackValue and WhiteValue are specified by the values of the variables, Black Value and Black Value, respectively.