Seeing gray pixels when plotting a binary image (> 1024 x 1024 pixels)
2 views (last 30 days)
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).
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
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?
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:
Or update to release R2015b in which this issue should be resolved.