0

原始问题:原始问题

我有一个大小height x width = (1500,500)调整为(500,300).

I1包含以其坐标为特征的边界框(Top, Left, Bottom, Right)


当I1的大小改变时,如何重新调整边界框的坐标?这些公式正确吗?

   double newTop = Math.Ceiling((top) * (double)pictureBox1.Height / (double)image1.Height);
   double newLeft = Math.Ceiling((left) * (double)pictureBox1.Width / (double)image1.Width);
   double newBottom = Math.Ceiling((bottom + 1) * (double)pictureBox1.Height / (double)image1.Height) - 1;
   double newRight = Math.Ceiling((right + 1) * (double)pictureBox1.Width / (double)image1.Width) - 1;

4

1 回答 1

1

一般来说:

尺寸按因子(新尺寸)/(旧尺寸)缩放。

坐标有点复杂:

x2 = left2 + (x1 - left1) * width2 / width1
y2 = top2 + (y1 - top1) * height2 / height1

whereleftwidth等描述了整个图像的位置。 xy描述正在转换的特征。在您的情况下,边界框的角是特征。

如果left1, left2, top1,top2都为零,您将得到与您相似的表达式。

于 2014-09-15T14:43:56.993 回答