MATLAB: How to obtain the pixel information for an image applied to a surface graphics object using IMPIXELINFO in Image Processing Toolbox 5.1 (R14SP3)

Image Processing Toolboximpixelinfopixvalsurftexturemap

I have applied my image on a SURF plot. I want to see the pixel information for my image using IMPIXELINFO. I use the following commands in MATLAB to achieve this:
[r1, t1] = meshgrid(0:0.2:1.0,0:15:360); s
[a b] = pol2cart(t1*pi/180,r1);
S = surf(a,b,ones(size(a)))
Pic= imread('cameraman.tif'); % read the image
set(S,'FaceColor','Texturemap','CData',Pic); % set properties to handle S.
view(2); %view the image for 2-d
impixelinfo % display pixel information
I receive the following error: ERROR: ??? Error using ==> impixelinfo The figure must contain at least one image.
How do I obtain the pixel values for my image?

Best Answer

The IMPIXELINFO function works only on objects of type 'Image'. Since 'S' is an object of type 'Surface', the PIXVAL function will not work. You may use the functions GETFRAME and IMSHOW to display the image as follows:
[r1, t1] = meshgrid(0:0.2:1.0,0:15:360);
[a b] = pol2cart(t1*pi/180,r1);
S = surf(a,b,ones(size(a)))
Pic = imread('cameraman.tif');
set(S,'FaceColor','Texturemap','CData',Pic);
view(2);
axis image; %change the axis to fit the image tightly
p=getframe; %get a frame from the current axes.
imshow(p.cdata(:,:,1)); % display the data as an image
impixelinfo % turn on pixel information
To read more on the functions GETFRAME, IMSHOW, and AXIS please refer the following links: