开发者

"Data dimensions must agree" Error

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜