Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Sobel and Scharr operators (#392)
* Implement Sobel and Scharr operators This commit adds Sobel and Scharr operators with support for 0th and 1st degrees with other degrees planned for later * Migrate and fix Harris example Generate Harris entries now uses signed image view. The Harris corner detector example now uses the Scharr filter generator and convolve_2d to reduce amount of code needed. * Fix and migrate Hessian example The Hessian example now uses signed image views and uses newly added kernel generators to compute gradients * Fix Harris and Hessian tests The tests broke due to migration to signed views in algorithms, but tests were not adjusted * Fix Jamfile for example/sobel_scharr.cpp * Cosmetic changes * Commented out fail tests * Fixed pixel16 used in image16s In Harris and Hessian tests, unsigned pixel values was used to construct signed image, which was causing appveyor to error out. * Reenable failing targets * Unify kernel generator interface This commit makes all kernel generator functions to return kernel_2d and adapts dependant threshold function to use the new interface * Migrate Hessian and Harris tests Migrate Hessian and Harris tests to new interface for kernel generators * Migrate Harris and Hessian examples Harris and Hessian examples now use new interface for kernel generation * Migrate simple_kernels tests simple_kernels are now using kernel_2d interface * Add missing return Normalized mean generation had missing return at the end of the function * Adapt code to namespace move This commit reacts to kernel_2d, convolve_2d being moved to namespace detail
- Loading branch information
1 parent
20f511b
commit 62379dd
Showing
16 changed files
with
357 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,7 @@ doc/warnings.txt | |
# Conan | ||
conaninfo.txt | ||
graph_info.json | ||
|
||
# clangd | ||
compile_commands.json | ||
.clangd/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ local sources = | |
dynamic_image.cpp | ||
histogram.cpp | ||
harris.cpp | ||
sobel_scharr.cpp | ||
; | ||
|
||
local targets ; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <boost/gil/typedefs.hpp> | ||
#include <boost/gil/image_processing/numeric.hpp> | ||
#include <boost/gil/extension/io/png.hpp> | ||
#include <boost/gil/extension/numeric/convolve.hpp> | ||
#include <string> | ||
#include <iostream> | ||
|
||
namespace gil = boost::gil; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
if (argc != 5) | ||
{ | ||
std::cerr << "usage: " << argv[0] << ": <input.png> <sobel|scharr> <output-x.png> <output-y.png>\n"; | ||
return -1; | ||
} | ||
|
||
gil::gray8_image_t input_image; | ||
gil::read_image(argv[1], input_image, gil::png_tag{}); | ||
auto input = gil::view(input_image); | ||
auto filter_type = std::string(argv[2]); | ||
|
||
gil::gray16_image_t dx_image(input_image.dimensions()); | ||
auto dx = gil::view(dx_image); | ||
gil::gray16_image_t dy_image(input_image.dimensions()); | ||
auto dy = gil::view(dy_image); | ||
if (filter_type == "sobel") | ||
{ | ||
gil::convolve_2d(input, gil::generate_dx_sobel(1), dx); | ||
gil::convolve_2d(input, gil::generate_dy_sobel(1), dy); | ||
} | ||
else if (filter_type == "scharr") | ||
{ | ||
gil::convolve_2d(input, gil::generate_dx_scharr(1), dx); | ||
gil::convolve_2d(input, gil::generate_dy_scharr(1), dy); | ||
} | ||
else | ||
{ | ||
std::cerr << "unrecognized gradient filter type. Must be either sobel or scharr\n"; | ||
return -1; | ||
} | ||
|
||
gil::write_view(argv[3], dx, gil::png_tag{}); | ||
gil::write_view(argv[4], dy, gil::png_tag{}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.