3D Plot of an 2D .bmp image
24 views (last 30 days)
Show older comments
Hi,
I am new to Matlab and having difficulties to plot an image. I try to plot an 2D colored .bmp image in a 3D plot.
My attempt was the naive one and feeding a 3D function with 2D input hoping for some descriptive error messages. Unfortunatly, the errors weren't descriptive...
lbimg = imread('x.bmp');
surf(lbimg);
Warning: Matrix dimensions must agree, not rendering mesh
Warning: Matrix dimensions must agree, not rendering mesh
I looked up the mesh function in the doc, but did not understood how to use htis function with my image.
Can anyone help me or give me a hint what to do next?
0 Comments
Answers (2)
Walter Roberson
on 17 Apr 2011
I'm not certain from your description, but it sounds to me as if you might want to use "texture mapping", which you can find described mostly under the patch() command.
0 Comments
Patrick Kalita
on 18 Apr 2011
It's a little unclear what kind of results you expected. My guess is that you have a color image which will be imported as an M-by-N-by-3 array, like this:
>> im = imread('peppers.png');
>> size(im)
ans =
384 512 3
The surf function expects an M-by-N array. So one option could be to just look at the red channel of the color image:
>> im_red = im(:,:,1);
>> size(im_red)
ans =
384 512
>> surf(double(im_red))
>>
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!