binary image shown in MATLAB GUI Window (can not seen, all black)

2 次查看(过去 30 天)
Hi, there. I have a problem in showing the binary image in MATLAB GUI Window by using 'cData'. Codes are shown as follows:
h_Img=handles.h_Img; %the image handle
Img_BW=handles.Img_BW; % the binary image
set(h_Img,'cData',Img_BW,'parent',handles.axes1);
This code lead to a black image. I cannot see the white part. But if I use this code
Img_BW=handles.Img_BW;% the binary image
figure;
imshow(Img_BW,[]);
It will show good image. Anyone can help me? Thank you.

采纳的回答

Image Analyst
Image Analyst 2017-6-12
My guess is that Img_BW is actually uint8, not logical so imshow(Img_BW) would show it with gray levels 0 and 1, which essentially appears black, whereas doing imshow(Img_BW, []) will map the 1 to 255 so now it will appear.
The other option is that the white parts are so small that when your image is shrunk down to fit on the screen, they're essentially subsampled away. However in this case you would not see them with the [] option. Show me what this shows in the command window when you put these lines of code before imshow():
whos Img_BW
min(Img_BW(:));
max(Img_BW(:));
  8 个评论
Image Analyst
Image Analyst 2017-6-12
1000 is not a problem (anymore). With old versions of MATLAB, all those images would pile on top of one another and you'd have to call cla between calles to imshow(), but now it seems like only one image is there. If you need to do several per second, then you might use cData, but if it's just like displaying a new image every second or slower, then that's fine and you won't notice any speed difference.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2017-6-10
colormap(gray(2))
  2 个评论
Penny
Penny 2017-6-12
Hi, thanks Walter Roberson. It doesn't work. I put the code like this:
Colormap(h_Img,gray(2));
set(h_Img,'cData',Img_BW,'parent',handles.axes1);
But it still shows nothing.
Penny
Penny 2017-6-12
Oh,sorry, my updated code is:
Colormap(handles.axes1,gray(2));
set(h_Img,'cData',Img_BW,'parent',handles.axes1);
But it still shows nothing.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by