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 commentaires

Adam
Adam le 5 Nov 2014
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 le 5 Nov 2014
yes Adam it is a comment to another question...But it is elaborated so I thought of keeping it as a new question

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 5 Nov 2014

0 votes

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 le 5 Nov 2014

0 votes

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 commentaires

sivaramakrishna
sivaramakrishna le 6 Nov 2014
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by