my requirement is I have to read two images and should compare the two images in terms of deformation.let me elaborate my question so that I can get a brief answer.For example there are two images say car I want to find the difference in terms of deformation.
I tried
a=imread();
surf(double(a));
shading flat;
but i am getting Warning: Matrix dimensions must agree, not rendering mesh

댓글 수: 2

Adam
Adam 2014년 11월 5일
Is this supposed to be a comment on another question? If it is a question in its own right it needs a bit more information since you clearly seem to be responding to an answer by 'Chad' to some previous question.
sivaramakrishna
sivaramakrishna 2014년 11월 5일
yes Adam it is a comment to another question...But it is elaborated so I thought of keeping it as a new question

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2014년 11월 5일

0 개 추천

You can't use surf() with a color image. Extract just one color channel or use rgb2gray() on it to convert (the badly-named) "a" to gray scale.
Mike Garrity
Mike Garrity 2014년 11월 5일

0 개 추천

I'm just guessing, but you would get that error message if your image was truecolor. In that case, a would be a MxNx3 variable with red, green, and blue values for each pixel. The surf command wants to display a single value as the height. It doesn't know what to do with 3 values.
If that's the case, then you need to convert the RGB triplets into a scalar value. For example:
surf(rgb2gray(a,3))
Once you've done that, you can use the RGB values as CData on the surface, just not as ZData. So you could do something like this:
a = imread('street1.jpg');
surf(rgb2gray(a,3),a,'EdgeColor','none')
Which would let you see the colors of your image on the surface, like this:

댓글 수: 2

sivaramakrishna
sivaramakrishna 2014년 11월 6일
Hi Mike,This answer is very useful for me.Could you please elaborate so that I can use according to my usage "compare two 3d images in terms of deformation". It is throwing an error rgb2gray sholud have only one argument
Well, I don't have a lot of info about what you're doing, but my guess was that you were trying to create a surface for each of two different images so that you could see the differences in where the bright & dark areas are. If so, it would look something like this:
img1 = imread('street1.jpg');
img2 = imread('street2.jpg');
surf(rgb2gray(img1),'EdgeColor','none','FaceColor','red');
hold on
surf(rgb2gray(img2),'EdgeColor','none','FaceColor','blue');
camlight
The idea is that each of the two calls to rgb2gray turns one of the RGB images into a scalar. Then the two calls to surf each turn one of these 2D scalar images into a surface.
I don't know whether I think it's a very effective visualization though. It might be in some use cases. I don't think that it's very helpful for the images I used here.

댓글을 달려면 로그인하십시오.

질문:

2014년 11월 5일

댓글:

2014년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by