MATLAB Answers


How do I eliminate (minimize) display quantization with imshow?

Asked by Bruce Pillman on 19 Aug 2013

I see extra quantization when displaying a grayscale uint8 image. For example:

inRamp = uint8 ( round ( repmat( linspace(0,60,1200), 600, 1 ) ) );
imshow ( inRamp)
imwrite ( inRamp, 'inputRamp.tif' )

If I display this tif image in another display application, I see a series of steps. The image displayed in MATLAB using imshow has a couple of steps that are double-wide and double-deep. I have verified this using Windows screen captures of the image as displayed by other software and as displayed in MATLAB. The plots of this data show a clear stairstep pattern, with the MATLAB showing a couple of steps (near pixel value 10 and 40) that are double width and double height. I can email plots to anyone interested in seeing them.



No products are associated with this question.

2 Answers

Answer by Bruce Pillman on 23 Aug 2013
 Accepted answer

After discussing this with Mathworks technical support, I tried changing the renderer used from "painters" to "opengl". This appears to solve the quantization problem.


Answer by Image Analyst
on 19 Aug 2013

You may be observing aliasing, possibly compounded by the Mach effect. Post your plots and images to


I did alt-printscreen and pasted into Photoshop and then saved out as PNG. Then I read it into MATLAB and extracted a line and plotted it. The plotted line (staircase ramp) did show some random jitter of plus or minus one gray level. I don't know why.

Thanks for doing that test. That is interesting, since my results don't seem random. I am running 64-bit Windows 7. What are you running?

The same.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!