Help with using SURF to analyze an image?

So I am trying to analyze and image using "surf" to make a 3D plot whose z value is the gray scale, where darker image will have lower z (Black is 0, White is 255). How would I use surf to analyze an image like that?

 採用された回答

Rik
Rik 2018 年 7 月 13 日

0 投票

What your goal is, is not really clear to me, but you can use the code below to view an image as a surf. I used an example image packaged with the IPT, so if you don't have that toolbox, you'll have to use your actual image.
figure(1),clf(1)
peppers = double(imread('peppers.png'));
IM=peppers(:,:,1)*.3+peppers(:,:,1)*.6+peppers(:,:,1)*.1;
[X,Y]= meshgrid(1:size(IM,2),size(IM,1):-1:1);
surf(X,Y,IM,'EdgeColor','none')
colormap('gray')
view(10,90)

6 件のコメント

Taylor Gates
Taylor Gates 2018 年 7 月 14 日
your code has me on the right track. Can you please explain the 4th line as far as what each one of those things does/represents for the final product?
Image Analyst
Image Analyst 2018 年 7 月 14 日
meshgrid just gives you a 2-D list of all the x,y coordinates in your image, which is what surf() wants.
That image doesn't look very 3D-ish.
Again, you would not use surf() to "analyze" an image unless it's just for you to qualitatively visualize and understand it better. It doesn't do any image analysis at all.
Taylor Gates
Taylor Gates 2018 年 7 月 14 日
So what would be the meaning of the -1,1? I guess I worded it poorly because all I needed to do was to quantify black and white values from 0-256 using surf
Image Analyst
Image Analyst 2018 年 7 月 14 日
That just flips it bottom to top because graphs (like surf) have the origin at the bottom left while images and matrices have the origin at the upper left.
I don't know what "quantify" means to you. The image is digital, so the values have already been quantized into 256 discrete levels. What do you mean?
Taylor Gates
Taylor Gates 2018 年 7 月 14 日
for example. If I delete the last line of the code you provided, it should display (in mine at least) a 3D surf of the grayscale. That is what I was trying to get.
Rik
Rik 2018 年 7 月 14 日
Just to clarify: you can still 3D rotate this. The line with view just sets the camera to a point where you can easily recognize the image.

サインインしてコメントする。

その他の回答 (2 件)

Image Analyst
Image Analyst 2018 年 7 月 13 日

0 投票

You wouldn't. The surf() function in base MATLAB just for visualization of smooth images, as opposed to SURF from the Computer Vision System Toolbox. The surf() function is not very good for visualizing rough images, and no good at all for analysis. See my Image Segmentation Tutorial in my File Exchange for an intro to image analysis.

タグ

質問済み:

2018 年 7 月 13 日

回答済み:

2018 年 7 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by