Problem with surf / pcolor / image

조회 수: 6 (최근 30일)
Michael
Michael 2011년 12월 1일
Hi
I have a matrix and I want a pcolor-style plot where each square (and therefore its colour) corresponds to an element. Currently each vertex corresponds to an element, so my images are getting distorted.
I'm trying to use image, but it's proving to be a very difficult function to manage- all I get is tiny plots of completely white images.
Is there a way to make a pcolor style image (ie. easy to manipulate without having to scale/resize which itself adds errors), only where the pixel colors are taken from individual elements of a matrix?
Thanks Mike

채택된 답변

Image Analyst
Image Analyst 2011년 12월 1일
You can use image, imagesc, or imshow (my preference). As you've probably found out, each square in pcolor does not correspond to an element in your array and the same element value will show up in different colors depending on where it is located. That is why I never ever use pcolor for displaying images.

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2011년 12월 1일
Use something like this:
pcolor(x,y,I),shading flat
That should give you your I with constant intensities for each pixel - or rather constant intensities for pixels I(1:end-1,1;end-1) with pixel I(i1,i2) mapped out to the patch with corners at:
[x([i1 i1 i1+1 i1+1],[i2 i2+1 i2+1 i2]);
y([i1 i1 i1+1 i1+1],[i2 i2+1 i2+1 i2])]
If you can survive without the last rrow and column this should be OK.
HTH

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by