OpenCV之图像梯度 – 拉普拉斯算子(二阶导数算子)

Posted MachineLP

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV之图像梯度 – 拉普拉斯算子(二阶导数算子)相关的知识,希望对你有一定的参考价值。

python代码:

import cv2 as cv
import numpy as np

image = cv.imread("./test.png")
cv.namedWindow("input", cv.WINDOW_AUTOSIZE)
cv.imshow("input", image)

h, w = image.shape[:2]
src = cv.GaussianBlur(image, (0, 0), 1)
dst = cv.Laplacian(src, cv.CV_32F, ksize=3, delta=127)
dst = cv.convertScaleAbs(dst)
result = np.zeros([h, w*2, 3], dtype=image.dtype)
result[0:h,0:w,:] = image
result[0:h,w:2*w,:] = dst
cv.imshow("result", result)
cv.imwrite("./aplacian.png", result)


cv.waitKey(0)
cv.destroyAllWindows()

C++代码:

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int artc, char** argv) 
	Mat image = imread("./test.png");
	if (image.empty()) 
		p

以上是关于OpenCV之图像梯度 – 拉普拉斯算子(二阶导数算子)的主要内容,如果未能解决你的问题,请参考以下文章

opencv python:图像梯度

OpenCV 边缘检测之Laplance算子

图像处理算法之模糊检测

图像处理算法之模糊检测

差分近似图像导数算子之Laplace算子

图像梯度