小编Sil*_*key的帖子

通过剪切的任意角度旋转(Paeth算法)

我正在尝试编写Alan Paeth描述的3剪切旋转算法的Java实现.问题不在于计算值,而是将旋转点拟合到图像网格上.在本文中,通过以下计算给出的3个连续剪刀进行旋转:

  1. x = x + alpha*y
  2. y = y + beta*x
  3. x = x + alpha*y

Alpha和beta由给定角度(θ;以弧度表示)通过以下公式计算:

  • beta = sin(theta)
  • alpha = - tan(theta/2)

使用这些公式,点围绕坐标系的中心旋转.

为了校正负值,我将相应轴的最小计算坐标添加到每个点,以使最小值始终为0.

到目前为止我的Java实现:

ShiftPoint[] val = new ShiftPoint[m*n];
double minX = 0,minY = 0, maxX = 0, maxY = 0;
double alpha = -1d*  Math.tan(Math.toRadians(theta)/2d);
double beta = Math.sin(Math.toRadians(theta));
for(int a = 0; a < m; a++) {
    for(int b = 0; b < n; b++) {
        ShiftPoint temp = new ShiftPoint(a, b, …
Run Code Online (Sandbox Code Playgroud)

java algorithm image-processing rotation

7
推荐指数
1
解决办法
627
查看次数

标签 统计

algorithm ×1

image-processing ×1

java ×1

rotation ×1