Problem with surf / pcolor / image

7 views (last 30 days)
Michael
Michael on 1 Dec 2011
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

Accepted Answer

Image Analyst
Image Analyst on 1 Dec 2011
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.

More Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 1 Dec 2011
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

Community Treasure Hunt

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

Start Hunting!