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

3 visualizaciones (últimos 30 días)
Ramin Dastanpour
Ramin Dastanpour el 9 de Oct. de 2015
Respondida: Martijn el 18 de Nov. de 2015
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).

Respuestas (3)

Walter Roberson
Walter Roberson el 9 de Oct. de 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.
  2 comentarios
Ramin Dastanpour
Ramin Dastanpour el 9 de Oct. de 2015
Thanks. I think you are right. However, I tried the suggested solution but it didn't solve the issue.
Walter Roberson
Walter Roberson el 9 de Oct. de 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.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 9 de Oct. de 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 comentarios
Ramin Dastanpour
Ramin Dastanpour el 9 de Oct. de 2015
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 el 9 de Oct. de 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?

Iniciar sesión para comentar.


Martijn
Martijn el 18 de Nov. de 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.

Community Treasure Hunt

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

Start Hunting!

Translated by