-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add matrix type and fix Hessian example
Sanitary_commit 1 2 3 4 5 5 5 Check Mac build Change CI trigger trait
- Loading branch information
1 parent
bd01761
commit 06fd700
Showing
11 changed files
with
253 additions
and
853 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: CI | ||
|
||
on: | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
|
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,47 @@ | ||
// | ||
// Created by shino on 13.08.21. | ||
// | ||
#include <boost/gil.hpp> | ||
#include <boost/gil/extension/io/png.hpp> | ||
#include <boost/gil/extension/numeric/matrix.hpp> | ||
#include <boost/gil/extension/numeric/arithmetics.hpp> | ||
|
||
namespace gil = boost::gil; | ||
|
||
#include <iostream> | ||
|
||
int main() { | ||
gil::gray8_image_t input_image; | ||
|
||
gil::read_image("input.png", input_image, gil::png_tag{}); | ||
auto input = gil::view(input_image); | ||
|
||
|
||
gil::matrix_storage matrix(input.dimensions()); | ||
auto view = gil::view(matrix); | ||
gil::value_cast(input, view); | ||
|
||
auto dx_kernel = gil::generate_dx_sobel(); | ||
auto dy_kernel = gil::generate_dy_sobel(); | ||
|
||
gil::matrix_storage dx_matrix(input.dimensions()); | ||
gil::matrix_storage dy_matrix(input.dimensions()); | ||
auto dx = gil::view(dx_matrix); | ||
auto dy = gil::view(dy_matrix); | ||
|
||
gil::convolve_2d<gil::elem_t>(view, dx_kernel, dx, gil::boundary_option::extend_constant); | ||
gil::convolve_2d<gil::elem_t>(view, dy_kernel, dy, gil::boundary_option::extend_constant); | ||
|
||
gil::gray8_image_t output_image(input.dimensions()); | ||
auto output = gil::view(output_image); | ||
auto max_derivative_value = 4.0 * 255.0; | ||
gil::abs_remap_cast(dx, output, 0.0, max_derivative_value); | ||
gil::write_view("dx_output.png", output, gil::png_tag{}); | ||
gil::abs_remap_cast(dy, output, 0.0, max_derivative_value); | ||
gil::write_view("dy_output.png", output, gil::png_tag{}); | ||
|
||
gil::matrix_storage gradient_storage(input.dimensions()); | ||
gil::gradient(dx, dy, gil::view(gradient_storage)); | ||
gil::remap_cast(gil::view(gradient_storage), output, 0.0, max_derivative_value * std::sqrt(2.0)); | ||
gil::write_view("gradient.png", output, gil::png_tag{}); | ||
} |
Oops, something went wrong.