回覆列表
  • 1 # 施家小哥哥

    Mat magX = Mat(src.rows, src.cols, CV_32F);

    Mat magY = Mat(src.rows, src.cols, CV_32F);

    Sobel(image, magX, CV_32F, 1, 0, 3);

    Sobel(image, magY, CV_32F, 0, 1, 3);

    // 計算斜率

    Mat slopes = Mat(image.rows, image.cols, CV_32F);

    divide(magY, magX, slopes);

    // 計算每個點的梯度

    Mat sum = Mat(image.rows, image.cols, CV_64F);

    Mat prodX = Mat(image.rows, image.cols, CV_64F);

    Mat prodY = Mat(image.rows, image.cols, CV_64F);

    multiply(magX, magX, prodX);

    multiply(magY, magY, prodY);

    sum = prodX + prodY;

    sqrt(sum, sum);

  • 中秋節和大豐收的關聯?
  • 世界觀的重要組成部分?