imshow / pcolor ... inconsistent plotting

6 vues (au cours des 30 derniers jours)
Michael
Michael le 29 Mai 2012
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 commentaires
Michael
Michael le 29 Mai 2012
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?
Image Analyst
Image Analyst le 29 Mai 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.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 29 Mai 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?
  1 commentaire
Michael
Michael le 30 Mai 2012
Thanks. I'm converting all my code from pcolor into imshow for this very reason, I didn't know about the YDir reverse option.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by