Why does MATLAB resample display data for *some* large images and not others? Can this be turned off?

조회 수: 10 (최근 30일)
When displaying large images (i.e. images with dimension greater than the screen resolution) using IMSHOW, IMAGESC, and similar functions, MATLAB will downsample the displayed image (CData not manipulated). However, this only happens when my image has dimension below 2048 pixels (i.e. images with dimension larger than 2048 do not have display data manipulated). This can be demonstrated by simply padding an image just under 2048 pixels and zooming in on an area of high detail. Why? How can this be avoided? Example below.
% Create image with dimension = 2048
im = zeros(2048);
% Draw line pair down center of image
im(:,[1000,1002]) = 1;
% Display and zoom in (no line pair)
figure; imshow(im)
% Display portion of image with dimensions within screen resolution (line pairs visible)
figure; imshow(im(1:1010,1:1010))
% Create new image with dimension = 2049 (or larger)
im2 = zeros(2049);
% Draw line pair down center of image
im2(:,[1000,1002]) = 1;
% Display and zoom in (line pair now visible)
figure; imshow(im2)

답변 (1개)

Image Analyst
Image Analyst 2017년 1월 11일
I think it just depends on what rows and columns it decides to use when it does the resampling. For one case it might decide to use column 1000 with the line and you'll see it, and in another case it might decide to use column 1001 with no line and not use the 1000 line, so the line doesn't show up. It's downsampling in both cases, it's just using different sets of pixels.
  댓글 수: 5
Jered Wells
Jered Wells 2017년 1월 12일
편집: Jered Wells 님. 2017년 1월 12일
Image Analyst, thank you very much for your suggestion. I tried it with one modification - I used my own (problematic) image. See attachments (if they upload). I completely understand that displayed image quality cannot exceed the resolution limits of the display device. However, zooming to 1:1 (i.e. one image pixel to one display pixel) should provide a displayed image ROI with resolution matching the original image data. The problem (bug?) I've noted is that this only happens when the original image has dimensions greater than 2048 pixels or less than the screen resolution! The attachments show this very problem using the code you provided (1600% zoom). My original (2021x2021) DICOM image (read using DICOMREAD), even with extreme zoom, shows a poorly resolved bar phantom. However, the same image padded with 20 "zeros" on all sides (2061x2061) yields a faithful representation of the original image data when zoomed. There must be an exception built into MATLAB's core image display code - weather intentional or not - since this problem exists with all manner of image display functions (IMTOOL, IMAGESC, IMSHOW, etc.). Furthermore, there is something special about image dimension 2048. I suspect that it has to do with my monitor resolution being 1920x1080 and 2048 being the next highest power of two (2^11). What's even more interesting is that truncating the original 2021x2021 image so that the default display size falls at different %-ages (e.g. 33%, 50%) relative to my display resolution yields different subsampling! At 33% default zoom, I see 3x3 regions of displayed pixels with the same value, and at 50% default zoom, there are 2x2 regions of identical pixel values observed when zooming. I suspect this is a result of some nearest neighbor interpolation of the CData prior to display.
Now, I could just go pad all my images to get them over the 2048 pixel limit (or reduce my monitor resolution to be less than the minimum size of the images I intend to display), but I'm not interested in doing that. I would be more interested in helping to find the root cause of this buggy functionality. I'd be happy to take up the discussion offline with you or MATLAB is that is of more use. Otherwise, happy to continue here. Again, appreciative of your expertise.

댓글을 달려면 로그인하십시오.


Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by