开发者

Laplacian of Gaussian: how does it work? (OpenCV)

开发者 https://www.devze.com 2022-12-25 04:30 出处:网络
Does anybody know how does it work and how to do it using OpenCV? Laplacian can be calculated using OpenCV,

Does anybody know how does it work and how to do it using OpenCV? Laplacian can be calculated using OpenCV, but the result is开发者_JS百科 not what I expected. I mean I expect the image to be approximately constant contrast at background regions, but it is black, and edges are white. There are a lot of noise also, even after gauss filter. I filter image using gaussian filter and then apply laplace. I think what I want is done by a different way.


Laplacian of Gaussian is an edge-detection filter; the output is 0 in constant ('background') regions, and positive or negative where there is contrast. The reason why you're seeing black in the background regions is because OpenCV is just giving you the raw output; the kind of image you're describing (gray on background, with positive / negative edges in black or white) is produced after scaling the output into an appropriate range.

The output range varies depending on the actual kernel used, but it's always going to fit in a (-max, +max) range around zero where max is the maximum output magnitude of the filter kernel; to get the "typical" output image you need to scale that into a (0, 1) range (or (0, 255) if you're using 8-bit images).

You can perform the necessary scaling using the cvScale function, with 1/(2*max) as the scale factor and 0.5 shift. (Or for 8-bit images use 255/(2*max) scale and 128 shift.)

0

精彩评论

暂无评论...
验证码 换一张
取 消