Image processing getting the pixels per inch of an

2019-08-06 02:53发布

问题:

Simply put:

I have a image of a human body. I have two reference points which are the left and right waist locations. Let's say for example: (100,100) and (200,100) are the respective left and right waist locations.

In addition to those two points, I also know the "real life" inches value of the waist.

I am trying to take those three data points and extrapolate how many pixels = one inch in "real life". This shouldn't be that hard, but I'm having some type of brain block on this.

Looking for the simple formula. The one I started with is:

(RightPoint.X - LeftPoint.X) / 34"

This does not work. The smaller the waist gets, the larger the pixels per inch value. In the above, it would be 2.9 pixels == 1".

If I change the 34" to 10", it shoots up to 10 pixels == 1". Or maybe that's correct? Ugh...brain where are you tonight!?!?

The Question:

I'm looking for the correct formula that based on those three referential data points will allow me to determine how many pixels in the image == 1". So if I know in real life that the person's waist is 34 inches, I want to determine that in the image...let's say 2.5 pixels == 1 inch relative to the picture.

回答1:

Unfortunately you don't have enough information to work it out. Firstly, the waist measurement in real life is 3-D and goes all the way around the body, so for a start you would have to divide it by 2 to allow for the tape-measure going both across the front and the back of the body - so your 34" waist would mean your 100 pixels correspond to 17" - if the body was flat - which it isn't! And that is the problem.

Imagine the person had two thick pillows down the front of their trousers... that would affect their waist measurement (make it miles bigger) but, as they are down the FRONT of their trousers, it wouldn't affect the pixel width.

Sorry, you can't do it accurately. You could assume their waist was perfectly circular, then the 100 pixels would correspond to the projection of their waist, so 34" would be the circumference of the waist, which is pi x d. So you would say that 100 pixels = 34/pi or around 11".

So, in concrete terms:

34/pi inches = 100 pixels
10.8 inches = 100 pixels
1 inch = 100/10.8 pixels
1 inch = 9.25 pixels

But remember this is an approximation based on the waist being circular.