Getting the difference of the relations of two images

I have an image of size 640*640*3 and another image of size 125*314*3 . I want to get the ratio of the size of the second image to the first image, but I cannot find a way to do this.

I tried to use the traditional separation method and also use rdivide , but both of them do not work.

If I use the traditional approach to multiply the three-dimensional values โ€‹โ€‹of the image first, and 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 correct?

+5
source share
2 answers

I assume that you mean the area ratio between the two images. If so, just use width and height. It looks like you are using RGB images, so do not use the number of channels. However, the number of channels is canceled when you use them when searching for a relationship.

So yes, your approach is correct:

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

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

+3
source

It depends on what you mean by aspect ratio.

It looks like you have RGB images, so if you mean the area, then this is (640 * 640) / (125 * 314), if you mean the height, then this is 640/314, more options are also more specific in your question.

+1
source

Source: https://habr.com/ru/post/1239234/


All Articles