Problem with .tif images display in matlab

37 Ansichten (letzte 30 Tage)
Rohit Thokala
Rohit Thokala am 18 Dez. 2021
Bearbeitet: DGM am 18 Dez. 2021
I don't understand why my images (.TIF extension) are not showing clearly in MATLAB. When I try to view same picture in any other photo viewer app, I can see a clear image.Below I am attaching my image in matlab (on the left) and genral image in photo viewer(on the right). somebody please explain me what to do. Thanks in advance
I used the following simple code to display image in matlab.
img = imread("Water_T_90_t_inj_10_P_05_M10250.tif");
imshow(img)
  3 Kommentare
Rohit Thokala
Rohit Thokala am 18 Dez. 2021
Hi #Benjamin, I am attaching my image here. I can't upload .tif files directly so I am sending a Zipped version
Rohit Thokala
Rohit Thokala am 18 Dez. 2021
Bearbeitet: Rohit Thokala am 18 Dez. 2021
Thank you for the explanation 👍 @DGM

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

DGM
DGM am 18 Dez. 2021
Bearbeitet: DGM am 18 Dez. 2021
When displaying images, imshow(), etc. expect the data to be within a certain range. For floating point data, black is 0, white is 1. For (unsigned) integer data, black is 0, white is the largest value that the integer class can represent. For example, white is 255 for uint8, or 65535 for uint16.
Your image is uint16, but the data only spans 0-4095, so it's rendered as a nearly-black frame. Since the image is RGB, trying to use the displayrange parameter for imshow() (i.e. imshow(myimage,[])) isn't going to work as intended.
If all you want to do is display the image, you can do so a few different ways:
imshow(rescale(A));
or
imshow(mat2gray(A)); % the name is misleading; works fine with RGB
Both of the above will normalize the data to its extrema. The result is a floating-point image in the appropriate range of 0-1 and should display correctly.
If instead of merely displaying it, you wanted to use this as your working image, you could.
B = mat2gray(A);
If you wanted the working image to be a particular class, use im2uint16(), im2uint8(), etc. to cast and rescale the data correctly.
B = im2uint16(mat2gray(A));

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by