Seeing gray pixels when plotting a binary image (> 1024 x 1024 pixels)

3 次查看(过去 30 天)
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).

回答(3 个)

Walter Roberson
Walter Roberson 2015-10-9
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.
  2 个评论
Ramin Dastanpour
Ramin Dastanpour 2015-10-9
Thanks. I think you are right. However, I tried the suggested solution but it didn't solve the issue.
Walter Roberson
Walter Roberson 2015-10-9
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
Image Analyst 2015-10-9
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 个评论
Ramin Dastanpour
Ramin Dastanpour 2015-10-9
No. I have neither loaded a saved JPEG image nor resized the image. It's a binary image and its matrix is composed of only 1/0. As said, if I plot the smaller portion of the same matrix no gray pixel is shown.
Image Analyst
Image Analyst 2015-10-9
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
Martijn 2015-11-18
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.

Community Treasure Hunt

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

Start Hunting!

Translated by