Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Penny
Penny le 9 Juin 2017
Commenté : Penny le 12 Juin 2017
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.
  2 commentaires
Adam
Adam le 12 Juin 2017
What is the data type of Img_BW?
Penny
Penny le 12 Juin 2017
Hi, Adam, data type of Img_BW is logical

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 12 Juin 2017
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 commentaires
Image Analyst
Image Analyst le 12 Juin 2017
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.
Penny
Penny le 12 Juin 2017
Ok. Got it. Thank you very much.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 10 Juin 2017
colormap(gray(2))
  2 commentaires
Penny
Penny le 12 Juin 2017
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 le 12 Juin 2017
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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by