imshow / pcolor ... inconsistent plotting

조회 수: 6 (최근 30일)
Michael
Michael 2012년 5월 29일
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
Michael
Michael 2012년 5월 29일
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 2012년 5월 29일
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.

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

채택된 답변

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

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by