I want to meaning of this code, I do not understand

3 views (last 30 days)
IA = im2uint16(mat2gray(A, [Tmin Tmax]));
imwrite(IA,'A.tiff','tiff');
  12 Comments
Muhammad Waheed AZAM
Muhammad Waheed AZAM on 15 Jun 2022
@hero IA = im2uint16(mat2gray(A, [Tmin Tmax])); in that code now I want to know how im2uint16 implement

Sign in to comment.

Answers (2)

Muhammad Waheed AZAM
Muhammad Waheed AZAM on 15 Jun 2022
@KSSV @Konrad @Hiro I read the document but did not understand please help
  1 Comment
Muhammad Waheed AZAM
Muhammad Waheed AZAM on 15 Jun 2022
@hiro mat2gray(A,[0 1])
can you explain this code from the matrix plz

Sign in to comment.


Siraj
Siraj on 15 Jun 2022
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!

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!