im = im2double(imread('rice.png'));
[X Y]= meshgrid(1:size(im,1),1:size(im,2));
surf(zeros(size(im)),X,Y,im,'EdgeColor','none');
when i run this script it worked me fine but when i tried to change the image to RGB image it gives me this 2 errors
??? Error using ==> surf at 78 Data dimensions must agree.
Error in ==> CoOrdinating at 6 surf(zeros(size(im)),X,Y,im,'EdgeColor','none');
i tried to convert the image to grayscale but it di开发者_JS百科dn't work with me and gave me the same errors
any help ?
I have a funny feeling you forgot to pass the grayscale image to the rest of the functions, because I also did it in my first attempt to run this code :P
im = im2double(imread('rice.png'));
if (isrgb (im))
im2 = rgb2gray (im);
else
im2 = im;
end
[X Y] = meshgrid (1:size(im2,1), 1:size(im2,2));
surf(zeros (size(im2)),X,Y,im2,'EdgeColor','none')
This worked for me (with an rgb image and a grayscale image)
精彩评论