Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining the ratio difference of two images

Tags:

image

matlab

I have an image of the size 640*640*3, while another image of the size 125*314*3. I want to obtain the size ratio of the second image to the first image, but I can't find a way to do it.

I have tried the traditional divide method, as well as using rdivide but both are not working.

If I use the traditional approach of multiplying the image 3D values first, then compare, will the approach be correct?

For example, I would do something like 640*640*3 = 1,228,800 then 125*314*3 = 117,750 and finally, take 117,750 / 1,228,800 = 0.09. Is 0.09 the right answer?

like image 534
Sammy Vellu Avatar asked Sep 25 '22 20:09

Sammy Vellu


2 Answers

I'm assuming you are referring to the ratio of the areas between the two images. If this is the case, just use the width and height. This looks like you are using RGB images, so don't use the number of channels. However, the number of channels cancels out when you use them in finding the ratio.

Therefore, yes your approach is correct:

(125*314) / (640*640) = 0.0958

This means that the smaller (or second) image occupies roughly 9.5% of the larger (or first) image.

like image 74
rayryeng Avatar answered Oct 11 '22 16:10

rayryeng


That depends what you mean by size ratio.

Looks like you have RGB images, so if you mean the area, then it is (640*640)/(125*314), if you mean the height, then it is 640/314, more options too, be more specific in your question.

like image 43
Koebmand STO Avatar answered Oct 11 '22 14:10

Koebmand STO