Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
Gin committed Nov 22, 2023
1 parent c17616f commit fff58a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ std::vector<std::pair<ImageRGB32, size_t>> filter_rgb32_range(
);


// If `replace_color_within_range` is true, replace the color within (<=) `max_euclidean_distance` of the
// If `replace_color_within_range` is true, replace the colors within (<=) `max_euclidean_distance` of the
// `expected_color` with `replacement_color`.
// If `replace_color_within_range` is false, replace the color outside of the distance with the color `replacement_color`.
// Returns the # of pixels inside the distance.
ImageRGB32 filter_rgb32_euclidean(
const ImageViewRGB32& image,
uint32_t expected_color, double max_euclidean_distance,
Color replacement_color, bool replace_color_within_range
);
// If `replace_color_within_range` is true, replace the colors within (<=) `max_euclidean_distance` of the
// `expected_color` with `replacement_color`.
// If `replace_color_within_range` is false, replace the color outside of the distance with the color `replacement_color`.
// Returns the # of pixels inside the distance.
ImageRGB32 filter_rgb32_euclidean(
size_t& pixels_in_range,
const ImageViewRGB32& image,
Expand Down
13 changes: 9 additions & 4 deletions SerialPrograms/Source/Tests/Kernels_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,12 @@ int test_kernels_FilterRGB32(const ImageViewRGB32& image){
const size_t height = image.height();
cout << "Testing filter_rgb32_range(), image size " << width << " x " << height << endl;

const uint32_t mins = combine_rgb(0, 0, 0);
// uint32_t maxs = combine_rgb(255, 255, 255);
const uint32_t maxs = combine_rgb(63, 63, 63);
Color min_color(0, 0, 0);
Color max_color(63, 63, 63);
// Color max_color(238, 24, 42);

const uint32_t mins = uint32_t(min_color);
const uint32_t maxs = uint32_t(max_color);

ImageRGB32 image_out(image.width(), image.height());
ImageRGB32 image_out_2(image.width(), image.height());
Expand Down Expand Up @@ -171,7 +174,9 @@ int test_kernels_FilterRGB32(const ImageViewRGB32& image){
const Color color(image.pixel(c, r));
const Color new_color(image_out.pixel(c, r));
const Color new_color_2(image_out_2.pixel(c, r));
bool in_range = (color.red() <= 63 && color.green() <= 63 && color.blue() <= 63);
bool in_range = (min_color.red() <= color.red() && color.red() <= max_color.red());
in_range = in_range && (min_color.green() <= color.green() && color.green() <= max_color.green());
in_range = in_range && (min_color.blue() <= color.blue() && color.blue() <= max_color.blue());
actual_num_pixels_in_range += in_range;
if (error_count < 10){
// Print first 10 errors:
Expand Down

0 comments on commit fff58a3

Please sign in to comment.