-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor expected image generation part
Add copyright header
- Loading branch information
Showing
4 changed files
with
109 additions
and
144 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// | ||
// Copyright 2019 Mateusz Loskot <mateusz at loskot dot net> | ||
// Copyright 2021 Prathamesh Tagore <[email protected]> | ||
// | ||
// Distributed under the Boost Software License, Version 1.0 | ||
// See accompanying file LICENSE_1_0.txt or copy at | ||
|
@@ -27,4 +28,54 @@ auto create_kernel(std::initializer_list<T> const& values) | |
return kernel; | ||
} | ||
|
||
template <typename SrcView, typename DstView> | ||
void row_conv1D_offset_img_generator(SrcView src_view, DstView dst_view, unsigned int const offset, | ||
std::ptrdiff_t start_row = 0, std::ptrdiff_t start_col = 0, std::ptrdiff_t end_row = -1, | ||
std::ptrdiff_t end_col = -1) | ||
{ | ||
BOOST_ASSERT(src_view.dimensions() == dst_view.dimensions()); | ||
static_assert(color_spaces_are_compatible | ||
< | ||
typename color_space_type<SrcView>::type, | ||
typename color_space_type<DstView>::type | ||
>::value, "Source and destination views must have pixels with the same color space"); | ||
|
||
if (end_row == -1) | ||
end_row = src_view.height(); | ||
if (end_col == -1) | ||
end_col = src_view.width(); | ||
for (std::ptrdiff_t y = start_row; y < end_row; ++y) | ||
{ | ||
auto src_it = src_view.row_begin(y); | ||
auto dst_it = dst_view.row_begin(y); | ||
for (std::ptrdiff_t x = offset + start_col; x < end_col; ++x) | ||
dst_it[x] = src_it[x - offset]; | ||
} | ||
} | ||
|
||
template <typename SrcView, typename DstView> | ||
void col_conv1D_offset_img_generator(SrcView src_view, DstView dst_view, unsigned int const offset, | ||
std::ptrdiff_t start_row = 0, std::ptrdiff_t start_col = 0, std::ptrdiff_t end_row = -1, | ||
std::ptrdiff_t end_col = -1) | ||
{ | ||
BOOST_ASSERT(src_view.dimensions() == dst_view.dimensions()); | ||
static_assert(color_spaces_are_compatible | ||
< | ||
typename color_space_type<SrcView>::type, | ||
typename color_space_type<DstView>::type | ||
>::value, "Source and destination views must have pixels with the same color space"); | ||
|
||
if (end_row == -1) | ||
end_row = src_view.height(); | ||
if (end_col == -1) | ||
end_col = src_view.width(); | ||
for (std::ptrdiff_t x = start_col; x < end_col; ++x) | ||
{ | ||
auto src_it = src_view.col_begin(x); | ||
auto dst_it = dst_view.col_begin(x); | ||
for (std::ptrdiff_t y = offset + start_row; y < end_row; ++y) | ||
dst_it[y] = src_it[y - offset]; | ||
} | ||
} | ||
|
||
}}}} // namespace boost::gil::test::fixture |