imageproc icon indicating copy to clipboard operation
imageproc copied to clipboard

Implementing Laplacian and LaplacianEdgeDetector Builders for Laplacian Edge Detection

Open thecodergus opened this issue 2 years ago • 2 comments

This pull request adds two new builder structures, Laplacian and LaplacianEdgeDetector, to address the request in Issue #505 titled "Laplacian edge detection". These builders are designed to make it easy and flexible for users to perform Laplacian edge detection on grayscale images.

The Laplacian builder allows users to apply a Laplacian filter to a grayscale image. It provides the option to use the default Laplacian kernel or to apply a diagonal adjustment to the kernel. This diagonal adjustment changes the kernel to emphasize diagonal edges in the image. To maximize compatibility and maintainability, the Laplacian builder utilizes existing project functions, such as the filter3x3 function, for filtering the image.

The LaplacianEdgeDetector builder builds on the Laplacian builder and provides a complete edge detection solution. Users can customize the edge detection process by setting parameters such as the Gaussian blur sigma value and the edge threshold value. If these parameters are not provided, the builder will use default values (sigma = 1.4 for Gaussian blur and Otsu's method for edge threshold). The LaplacianEdgeDetector builder also offers an option for diagonal adjustment, similar to the Laplacian builder.

These new builders make it easy for users to perform Laplacian edge detection on grayscale images with just a few lines of code. The flexibility of the builders allows for customization of the edge detection process according to the user's needs. By leveraging existing functions within the project, these additions ensure seamless integration and improved maintainability. I believe these enhancements will be a valuable addition to the project and help users achieve better edge detection results.

thecodergus avatar Apr 15 '23 21:04 thecodergus

An entire struct for a Laplacian filter seems redundant. Maybe just 2 functions.

cospectrum avatar Mar 14 '24 22:03 cospectrum

An entire struct for a Laplacian filter seems redundant. Maybe just 2 functions.

The idea is to give freedom of customization within a certain scope, it is not as if the algorithm does not have variations.

thecodergus avatar Mar 18 '24 00:03 thecodergus

This is useful functionality to have, but I agree with @cospectrum that the builder types are unnecessary - a single function for filtering using the Laplacian kernel and a single function for computing edges would be better.

theotherphil avatar Apr 28 '24 12:04 theotherphil

Following guidance from @cospectrum and @theotherphil, changes have been made

thecodergus avatar Apr 28 '24 21:04 thecodergus

Thanks, @thecodergus !

theotherphil avatar Apr 29 '24 05:04 theotherphil

Unexpected errors occurred in the merge testing phase @theotherphil, in the version of the library that I forked and edited in the branch, the threshold function had the structure "threshold(image: &GrayImage, thresh: u8) -> GrayImage" but the current one has the structure "threshold(image: &GrayImage, threshold :u8, threshold_type: ThresholdType) -> GrayImage". In this case, I would use the ThresholdType::Binary enumerator in contrast::threshold(&laplacian_img, otsu_threshold, /* contrast::ThresholdType */).

thecodergus avatar Apr 29 '24 13:04 thecodergus

Unexpected errors occurred in the merge testing phase @theotherphil, in the version of the library that I forked and edited in the branch, the threshold function had the structure "threshold(image: &GrayImage, thresh: u8) -> GrayImage" but the current one has the structure "threshold(image: &GrayImage, threshold :u8, threshold_type: ThresholdType) -> GrayImage". In this case, I would use the ThresholdType::Binary enumerator in contrast::threshold(&laplacian_img, otsu_threshold, /* contrast::ThresholdType */).

He fixed it https://github.com/image-rs/imageproc/pull/582

cospectrum avatar Apr 29 '24 13:04 cospectrum

It's borken I think https://github.com/image-rs/imageproc/issues/585

cospectrum avatar Apr 29 '24 20:04 cospectrum

It's borken I think #585

I wanted to make sure, so I tested it again, and fortunately, it still seem to be working correctly. Could you please help me take another look at it? ovo1 ovo1_laplace

thecodergus avatar Apr 29 '24 22:04 thecodergus