• 图像绕X,Y,Z轴旋转效果


    原图:

    绕垂直轴旋转:

     绕水平轴旋转:

    绕中心点旋转:

    Mat warpPerspective(Mat src, float angle, int mode)
    {
    angle *= 0.0174533;
    int height = src.rows;
    int width = src.cols;

    Mat outMat(height, width, CV_8U, 255);

    double ri0 = height*0.5;
    double rj0 = width*0.5;

    float ratio = sin(angle);


    if (mode == 1)
    {
    double ri0 = height*0.5;
    double rj0 = width*0.5;


    for (int i = 0; i < height; i++)
    {
    for (int j = 0; j < width; j++)
    {

    int srci = -(j - rj0)*sin(angle) + (i - ri0)*cos(angle) + ri0;
    int srcj = (j - rj0)*cos(angle) + (i - ri0)*sin(angle) + rj0;

    if (srci >= 0 && srci < width && srcj >= 0 && srcj < height)
    outMat.ptr<uchar>(i)[j] = src.ptr<uchar>(srci)[srcj];

    }
    }
    }

  • 相关阅读:
    Gitbook
    Docker命令
    sd
    文本三剑客
    2017.4.12下午
    2017.4.11下午
    2017.4.11上午
    2017.4.10下午
    2017.4.10上午
    2017.4.7下午
  • 原文地址:https://www.cnblogs.com/taotaoland/p/9082932.html
Copyright © 2020-2023  润新知