Changing image rendering?

Hey All,
attempting to visualize a raster of lines and running into issues. When the lines are plotted as lines, the image appears correctly, as follows:
When attempting to visualize the same lines (ignoring the large vertical and horizontal lines), I get the following
zooming in, all the same lines are present, just zoomed out they have varying degrees of visibility. Is there a way to modify MATLAB handling of this image to produce an image closer to what appears above?

1 comentario

Oliver Woodford
Oliver Woodford el 21 de Sept. de 2020
Editada: Oliver Woodford el 21 de Sept. de 2020
I'm just wondering why, if the results using plot are correct, or what you want, why you're trying to rasterize the lines. What is wrong with the approach using plot? If it's rendering time, please share how you call plot.

Iniciar sesión para comentar.

Respuestas (1)

Oliver Woodford
Oliver Woodford el 17 de Sept. de 2020
Editada: Oliver Woodford el 17 de Sept. de 2020

0 votos

Basically you are rendering a binary image, and you're getting gray levels instead of just black and white?
What are you using to render the image? imshow() can rescale the image if it is too large. imagesc() doesn't do this.
For example:
>> A = rand(50, 4000) < 0.99;
>> imagesc(A);
>> colormap(gray(256));
when zoomed in gives:

13 comentarios

aboharbf
aboharbf el 17 de Sept. de 2020
It is already binary. they are arrays of roughly 5 - 20 rows with ~4000 columns, every entry is 0 or 1.
Walter Roberson
Walter Roberson el 17 de Sept. de 2020
spy(data) ?
Oliver Woodford
Oliver Woodford el 17 de Sept. de 2020
See my updated answer.
aboharbf
aboharbf el 17 de Sept. de 2020
So the issue isn't when it is zoomed out, my hope is to recapitculate the behavior of drawing tick marks w/ plot() using an image drawing function instead, since im drawing many hundreds if not thousands of ticks.
I was using imagesc(), and I realize the image isn't 'big enough', but I wanted to know how to drive the behavior to get closer to the fully drawn line way. It does seem like your sc functions improved things. I will investigate the smoothing and vertexcenter function next. Thank you both!
Walter Roberson
Walter Roberson el 17 de Sept. de 2020
You get gray from binary when MATLAB applies anti-aliasing, especially when you are trying to render more data pixels than fit into the physical pixels.
Oliver Woodford
Oliver Woodford el 17 de Sept. de 2020
It's not possible to do using any of the builtin image rendering functions. They will either blur or do nearest neighbor downsampling, in which case you get gray or lose lines. The plot function renders a line, however zoomed out you are. This is akin to resampling using the min() operator. What you can do is resample in the x direction by taking the min over blocks of columns (or max if your sparse lines are represented by 1s, not 0s).
aboharbf
aboharbf el 18 de Sept. de 2020
Walter - I attempted to find the 'AlignVertexCenters' property of my figures but it doesn't exist. Not sure why. I'm using 2019b.
Oliver - Would this need to be setup via a custom callback or are there any methods available to do something like this?
Walter Roberson
Walter Roberson el 18 de Sept. de 2020
AlignVertexCenters is a line property, not a figure property and not an image property.
aboharbf
aboharbf el 18 de Sept. de 2020
Then in this case, it seems like it would defeat the purpose, since I'm trying to get rid of the greys present in an image as a way of avoiding the much more computationally taxing task of drawing many lines. It is a handy thing to know about though, so thank you for sharing.
Oliver Woodford
Oliver Woodford el 18 de Sept. de 2020
I was suggesting shrinking your image to the resolution you intend to visualize it on screen, before passing it to the rendering function, rather than have some kind of callback which actively resizes the image to fit the zoom. Do you need to have the ability to interactively zoom in?
Walter Roberson
Walter Roberson el 18 de Sept. de 2020
The features I pointed to are the only graphics smoothing and anti-aliasing available. In particular the GraphicsSmoothing figure property would be the one applicable.
Walter Roberson
Walter Roberson el 18 de Sept. de 2020
Maybe conv2() the array with ones() the size of the number of data pixels that will be rendered down to one physical pixel, and logical() the result. That would be equivalent to an OR operation over the entire block.
aboharbf
aboharbf el 20 de Sept. de 2020
@Oliver - I do need the ability to interactively zoom in and out.
@ Walter - I tried the Graphics smoothing but it didn't appear to have any influence unfortunately. Likely due to the plot being purely vertical lines. The function you describe may be worth a shot though, thanks for the tip.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Exploration en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Abr. de 2020

Editada:

el 21 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by