DataAspectRatio, DataAspectRatioMode image display bug

2 views (last 30 days)
I've been trying to get pixel accuracy when displaying medical images. It started when I noticed nearest neighbor interpolation aliasing artefacts similar to what's discussed here (link). Not having the image processing toolbox, I wrote my own function that properly interpolates (and does anti-aliasing when shrinking), like imresize does. However, I'm still getting some duplicate pixel rows/columns for some sizes, with certain combinations of properties of the axes.
Specifically, unless DataAspectRatioMode is 'auto', I'll get some artefacts for some image sizes. Not many, but one or two rows/columns sometimes and it's very noticeable. If I use the same image and plot it in another figure with image(Data), then it looks fine (default DataAspectRatioMode is 'auto', and that seems to give the aspect ratio [max(size(Data)), max(size(Data)), 1], instead of [1, 1, 1]. Weirder is that even if I keep the same DataAspectRatio, just changing the mode from 'auto' to 'manual' and back makes the artefact appear and disappear.
So although I have a workaround, my question really is: why does it not work with 'manual' aspect ratio (which I always had at [1, 1, 1], or the same value given by 'auto')? I should add that my Data has the same size as the axes [Height, Width] as obtained from the Position property. And I set 'XData'/'YData' the same way as the default: [1, N], and 'XLim'/'YLim' to [0.5, N+0.5]. So I'm thinking the height and width returned by Position may not correspond exactly with the display area of the axes? With "axes on", switching DataAspectRatioMode does make an extra pixel appear left and top, and if you plot a large "~eye" matrix, you can tell there's an extra pixel bottom and right, but those disappear with "axes off". So lots of strange details. Do we know for sure what the display area is in pixels in each of these scenarios? Is it actually width/height minus 1 or minus 2? If it really were what Position returned I don't see why Matlab would ever interpolate my Data and give these artefacts.
I'm on R2011b by the way. Thanks!

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!