Home > Back-end >  C the coordinate transformation in the digital image processing
C the coordinate transformation in the digital image processing

Time:10-13

I recently watching the program is the place in pixel coordinates is derived, after the mathematical formula derived with programming when finally why is added a 0.5 (+ 0.5)
Such as mathematical formulas are X1 X2=/b (image scaling), (the X1 is the original pixel coordinates, the X2 is a new pixel coordinates) and by the program becomes i1=(long) (I/c + 0.5); I1 is equivalent to the X1 here, I would be equivalent to X2, C is equivalent to b, I don't know here for agency yao to add (+ 0.5), please explain the good man!

CodePudding user response:

Screen coordinates (0, 0) is its corresponding the pixels (actual is a square pixels) center, 0.5 is the offset

CodePudding user response:

Should be to rounded, coordinates are int type, in the process of calculation is usually double or float, the calculation results directly from the whole error is bigger, + 0.5 can have the effect of rounding,

CodePudding user response:

Should be in the integer in order to ensure the rounding of truncation.
0.9 - such as "0.9 + 0.5=1.4-1; 0.4-0.4 + 0.5=0.9 - "" 0

CodePudding user response:

In order to the center of the corresponding pixel,

CodePudding user response:

Agree with 2 and 3 floor,
  • Related