Imported greyscale image into ImageLabeler, the main workspace shows the image as black, but Image Browser shows correct images

1 view (last 30 days)
Hi, I am working with images that are 48 x 48 pixels wide and are UINT8 greyscale PNG image files. I have checked the values in MATLAB workspace, and when I import the PNG files into MATLAB, and I check the values, the values are not all 0.
As you can see, the correct image is shown in the very bottom bar in Image Browser. However, the main workspace shows only black, which means I can't label the desired portion. I have tried my best to Google if another person has encountered this problem, but I coudn't find anything to the best of my ability.
  2 Comments
Claudia Chen
Claudia Chen on 8 Sep 2024
Edited: Claudia Chen on 8 Sep 2024
Hi apologies for not seeing this earlier, I checked my emails around this time yesterday and didn't see your comment.
I think the person below answered what is probably happening. My maximum value of my pixels here is 24 out of a scale of 255.

Sign in to comment.

Accepted Answer

DGM
DGM on 7 Sep 2024
Edited: DGM on 7 Sep 2024
A few things to know:
  1. The imageBrowser app will misrepresent grayscale images by automatically rescaling their dynamic range.
  2. The imageBrowser app will correctly display an indexed image using its color table.
  3. I don't know if the browser thumbnails in the imageLabeler are automatically rescaled
  4. I don't have any way to test whether the imageLabeler will correctly display an indexed image.
So with the uncertainty of #3 and #4, there are two possible explanations:
  1. Your image is a grayscale intensity image with a nonstandard narrow dynamic range.
  2. Your image is a grayscale image represented in indexed color, and the imageLabeler is ignoring its color table.
If #1, you could simply stretch the range of your data using mat2gray().
inpict = imread('cmannarrowrange.png'); % uint8, [0 24]
outpict = mat2gray(inpict); % rescale extrema to unit-scale float
imwrite(outpict,'mytempcopy.png')
montage({inpict outpict})
If the labeler can't handle an indexed-color image, then:
[inpict CT] = imread('cmanmvqidx16.png'); % uint8, [0 15] indexed
outpict = ind2gray(inpict,CT); % convert to intensity image
imwrite(outpict,'mytempcopy.png')
montage({inpict outpict})
I'm going to guess that it's #1, but I don't have CVT, so I can't test the labeler app's behavior. Attached are two test images which should be useful to determine what the app and its thumbnailer will read correctly.
  1 Comment
Claudia Chen
Claudia Chen on 8 Sep 2024
Edited: Claudia Chen on 8 Sep 2024
Hello,
Thank you so much. I didn't check whether my data would be normally visible because the Matlab image previews keep scaling the range of the images even in the normal workspace of the original Matlab. My maximum value in that image was 24/255 which is pretty dark.
Thank you again.

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!