Why figure doesn't render properly? (Opengl painters)
5 views (last 30 days)
I was trying to save a uint8 3D RGB matrix into png format with print(), but some pixels showed undesired shades. First try, I was saving a simple magenta rectangle (matrix 300x600x3) and the shades were on the borders: I solved setting the renderer to 'painters' (figures attached)
But when I tried the same on a much larger matrix (945x2556x4355) with more complex plot, even '-painters' does not work
Maybe here is not very clear, but in the original output I just want white and magenta pixels, while you can see here there are a lot of pink and grey shades that (I checked it) are not present in the original matrix and they don't show up when I display the image with imshow(). It's a matter of how Matlab represent the output.
I've read that Matlab can't mantain 'painters' for complex plot and adjust automatically the renderer to Opengl, so I tried to force it with several solutions:
imshow(layer1) % my matrix
fig.PaperPosition=[0 0 288 144]; % I need a 600x300 pixel output
but they work only for the simple rectangle.
Any hint? Thanks in advance
Robert U on 14 Oct 2022
Hi Simone Cotta Ramusion,
as suspected I could reproduce the smoothing at the edges. Setting smoothing off, eliminates the shaded starting and ending pixels in each line. Even I use the default renderer.
fig.PaperPosition=[0 0 288 144]; %
fig.GraphicsSmoothing = 'off';