Seeing gray pixels when plotting a binary image (> 1024 x 1024 pixels)
3 views (last 30 days)
Show older comments
I have a few binary images (~ 1400x1500 and larger) and when I plot each of them using imshow it shows me some gray pixels. Well using data cursor the values of these pixels are either 0 or 1. So why do I get such an image? And how can I avoid this? I need to show the real binary image so I can apply further calculations (connecting and breaking structures) on the image manually. I don't have this problem when plotting smaller portions of the same binary image (but I need the full scale image and will zoom in different parts of the next steps of my image processing).
The problem happens when width and/or length of the image are/is larger than 1024 pixels.
Sample image of a part of big image (zoomed and saved):
The same part of the image plotted separately (imshow(BW(x1:x2,y1:y2)). This is what I want. Real scales and each pixel on the shown image being representative of the exact same pixel in the actual image; and no gray pixel (just pure white or black).
0 Comments
Answers (3)
Walter Roberson
on 9 Oct 2015
When the image has more pixels than the width (or height) of your plotting area in pixels, then more than one image pixel needs to be mapped into screen pixels. The algorithm for doing that has to weight several pixels to decide what screen pixel to present. The result might be gray.
If you are using R2014b or later you might wish to investigate http://www.mathworks.com/matlabcentral/answers/157758-how-do-i-turn-off-antialiasing-in-matlab-r2014b
2 Comments
Walter Roberson
on 9 Oct 2015
Solution 1: Do not try to display an image in too small of an area for it
Solution 2: imresize() and logical() the result and display that
When you try to display more pixels of information than fit in an area, something has to give. As it is now you can see exactly which points are being affected; if you were to force it to two tone then you would not know which pixels were accurate representations of the input and which pixels had been altered to represent more data than would fit.
Image Analyst
on 9 Oct 2015
It looks like you either saved these images as a JPEG image (bad idea) and then recalled it, and so you have JPEG artifacts, or else you resized your binary image and it anti-aliased it to produce smooth edges. You must have done something like that. Maybe it's just the display. Did you actually look at the actual binary image in the variable editor?
2 Comments
Image Analyst
on 9 Oct 2015
Binary images are not gray. You did something and I can't tell what it is unless you show your code.
And please answer my question about whether you saw any values other than 0 and 1 in the variable editor. And is the class of the image logical, like it should be, or is it uint8 or double, which it should not be?
Martijn
on 18 Nov 2015
This is an issue which may occur in MATLAB R2015a when working with the OpenGL renderer in software mode. If possible try switching to OpenGL hardware renderering:
opengl hardware
Or update to release R2015b in which this issue should be resolved.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!