I want to meaning of this code, I do not understand
1 次查看(过去 30 天)
显示 更早的评论
IA = im2uint16(mat2gray(A, [Tmin Tmax]));
imwrite(IA,'A.tiff','tiff');
12 个评论
Hiro Yoshino
2022-6-15
I = mat2gray(A,[amin amax]) converts the matrix A to a grayscale image I that contains values in the range 0 (black) to 1 (white). amin and amax are the values in A that correspond to 0 and 1 in I. Values less than amin are clipped to 0, and values greater than amax are clipped to 1.
Note that this is a copy of the documentation.
matrix A is something like:
A = rand(10)
I = mat2gray(A,[0 1])
If you show this A as an image, it goes ....
imshow(I)
回答(2 个)
Siraj
2022-6-15
Hi,
It is my understanding that you want to understand what this code is doing.
As per my understanding, in first line of code the matrix ‘A’ is converted to a grayscale image that contains values in the range 0 (black) to 1 (white). ‘Tmin’ and ‘Tmax ’ are the values in A that correspond to 0 and 1 in image matrix. Values less than ‘Tmin’ are clipped to 0, and values greater than ‘Tmax’ are clipped to 1.
After this ‘im2uint16’ will convert the image matrix to a 16-bit unsigned integer, rescaling and offsetting the image matrix.
The second line of the code will write the matrix ‘IA’ to a graphics file ‘A.tiff’, the third argument to the function ‘imwrite’ that is ‘tiff’ makes sure that the format of the file is .tiff no matter what extension you give in the file name.
Please refer to mat2gray, im2uint16 and imwrite documentation for more information about these functions.
Hope it helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!