And as a further question am I right in saying, to plot a matrix using Cartesian convention, it is necessary to write "imshow(flipud(I'));" ? And the transpose must be inside the second bracket?
imshow / pcolor ... inconsistent plotting
6 views (last 30 days)
Show older comments
Hi
Just asking to confirm something as I have never noticed this before and it's confusing me a bit. I'll use a simple example matrix; I = zeros(100); I(10:20,45:55) = 1; imshow(I) figure; pcolor(I);
In my geometry I'm using a matrix to represent (x,y) Cartesian coordinates which are represented by rightward,upward increasing coordinates, respectively. inshow appears to flip x/y and also flip the matrix up/down before plotting, and pcolor appears to just flip x/y. Is this correct?
I've been trying to fix a problem for a while, all the time not knowing that these two imagine options return different results! If my above statement is correct then I should hope that I have no actual coding problem at all.
Thanks very much, if anyone more familiar with this than me can confirm it. Mike
2 Comments
Image Analyst
on 29 May 2012
No, you're better off reversing the standard image direction to be the Cartesian direction using the ydir property:
set(gca, 'YDir', 'reverse');
That way you don't waste time creating a new array that is flipped just for display.
Accepted Answer
Image Analyst
on 29 May 2012
imshow() does not flip vertically. It uses the standard convention of the top line of the image being row #1. Totally standard. Not flipped. Everyone who deals with images does it this way.
Don't use pcolor for images. pcolor does something vastly different than imshow. You don't have the same number of "squares" for each pixel (it's one row short in each dimension) and the colors do not correspond to the image values but to the "tilt" of the square between the four corners (unless you use the flat shading option). Why would you want to use pcolor?
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!