Skip to content

Commit 1dcc9c2

Browse files
author
Gin
committed
more comments for filter_by_mask() code
1 parent 2620f96 commit 1dcc9c2

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

SerialPrograms/Source/CommonFramework/ImageTools/BinaryImage_FilterRgb32.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ namespace PokemonAutomation{
2121
void filter_by_mask(
2222
const PackedBinaryMatrix& matrix,
2323
ImageRGB32& image,
24-
Color replace_with,
25-
bool replace_if_zero // If false, replace if one.
24+
Color replacement_color,
25+
bool replace_zero_bits
2626
){
2727
if (matrix.width() > image.width()){
2828
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Image width is too small.");
@@ -33,14 +33,14 @@ void filter_by_mask(
3333
Kernels::filter_by_mask(
3434
matrix,
3535
image.data(), image.bytes_per_row(),
36-
(uint32_t)replace_with, replace_if_zero
36+
(uint32_t)replacement_color, replace_zero_bits
3737
);
3838
}
3939
void filter_by_mask(
4040
const PackedBinaryMatrix& matrix,
4141
ImageRGB32& image, size_t offset_x, size_t offset_y,
42-
Color replace_with,
43-
bool replace_if_zero // If false, replace if one.
42+
Color replacement_color,
43+
bool replace_zero_bits
4444
){
4545
if (matrix.width() > image.width()){
4646
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Image width is too small.");
@@ -53,7 +53,7 @@ void filter_by_mask(
5353
matrix,
5454
(uint32_t*)((char*)image.data() + bytes_per_row * offset_y + offset_x * sizeof(uint32_t)),
5555
bytes_per_row,
56-
(uint32_t)replace_with, replace_if_zero
56+
(uint32_t)replacement_color, replace_zero_bits
5757
);
5858
}
5959

SerialPrograms/Source/CommonFramework/ImageTools/BinaryImage_FilterRgb32.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,27 @@
1818
namespace PokemonAutomation{
1919

2020

21-
21+
// Selectively replace pixels in `image` with the replacement color
22+
// according to the respective bits in the binary matrix.
23+
// If `replace_zero_bits` is true, replace pixels corresponding to the zero bits.
24+
// Else, replace those with the one bits.
2225
void filter_by_mask(
2326
const PackedBinaryMatrix& matrix,
2427
ImageRGB32& image,
25-
Color replace_with,
26-
bool replace_if_zero // If false, replace if one.
28+
Color replacement_color,
29+
bool replace_zero_bits
2730
);
31+
// Selectively replace pixels in an area of the `image` with the replacement color
32+
// according to the respective bits in the binary matrix.
33+
// If `replace_zero_bits` is true, replace pixels corresponding to the zero bits.
34+
// Else, replace those with the one bits.
35+
// The image area starts at (offset_x, offset_y) with the same (width, height) as
36+
// the matrix.
2837
void filter_by_mask(
2938
const PackedBinaryMatrix& matrix,
3039
ImageRGB32& image, size_t offset_x, size_t offset_y,
31-
Color replace_with,
32-
bool replace_if_zero // If false, replace if one.
40+
Color replacement_color,
41+
bool replace_zero_bits
3342
);
3443

3544

SerialPrograms/Source/Kernels/BinaryImageFilters/Kernels_BinaryImage_BasicFilters.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ namespace PokemonAutomation{
2828
namespace Kernels{
2929

3030

31-
// Selectively replace each pixel in an image with the specified pixel
32-
// according to the respective bit in the binary matrix.
31+
// Selectively replace pixels in an image with the replacement color
32+
// according to the respective bits in the binary matrix.
33+
// If `replace_zero_bits` is true, replace pixels corresponding to the zero bits.
34+
// Else, replace those with the one bits.
3335
void filter_by_mask(
3436
const PackedBinaryMatrix_IB& matrix,
3537
uint32_t* image, size_t bytes_per_row,
36-
uint32_t replace_with,
37-
bool replace_if_zero // If false, replace if one.
38+
uint32_t replacement_color,
39+
bool replace_zero_bits
3840
);
3941

4042

0 commit comments

Comments
 (0)