Skip to content

Commit c8a5013

Browse files
author
Gin
committed
minor comment update
1 parent 1361390 commit c8a5013

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

SerialPrograms/Source/CommonFramework/ImageTools/ImageDiff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void scale_brightness(ImageRGB32& image, const FloatPixel& multiplier);
3232
//
3333
// If (reference.alpha == 255) Count the pixel.
3434
// If (reference.alpha == 0) Ignore the pixel and exclude from pixel count.
35-
//
35+
// Alpha channel of "image" is ignored.
3636
double pixel_RMSD(const ImageViewRGB32& reference, const ImageViewRGB32& image);
3737

3838

@@ -42,7 +42,7 @@ double pixel_RMSD(const ImageViewRGB32& reference, const ImageViewRGB32& image);
4242
//
4343
// If (reference.alpha == 255) Count the pixel.
4444
// If (reference.alpha == 0) Replace reference pixel with "background".
45-
//
45+
// Alpha channel of "image" is ignored.
4646
double pixel_RMSD(const ImageViewRGB32& reference, const ImageViewRGB32& image, Color background);
4747

4848

SerialPrograms/Source/CommonTools/ImageMatch/ExactImageMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace PokemonAutomation{
1414
namespace ImageMatch{
1515

1616

17-
// Match images against a template.
17+
// Match images against a template image.
1818
// Before matching, resize the input image to the template shape and scale template brightness to
1919
// match the input image. Alpha channels as used as masks in matching.
2020
// No other treatment like tolerating translation or scaling based on stddevs, hence the name "Exact".

SerialPrograms/Source/CommonTools/ImageMatch/WaterfillTemplateMatcher.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,23 @@ WaterfillTemplateMatcher::WaterfillTemplateMatcher(
5959
);
6060
}
6161

62-
const WaterfillObject* best = &objects[0];
62+
const WaterfillObject* largest_object = &objects[0];
6363
for (const WaterfillObject& object : objects){
64-
if (best->area < object.area){
65-
best = &object;
64+
if (largest_object->area < object.area){
65+
largest_object = &object;
6666
}
6767
}
6868

69-
m_matcher.reset(new ExactImageMatcher(extract_box_reference(reference, *best).copy()));
70-
m_area_ratio = best->area_ratio();
69+
m_matcher.reset(new ExactImageMatcher(extract_box_reference(reference, *largest_object).copy()));
70+
m_area_ratio = largest_object->area_ratio();
7171

7272
// cout << "template area ratio = " << m_area_ratio << endl;
7373

7474
if (PreloadSettings::debug().IMAGE_TEMPLATE_MATCHING){
75-
const auto exact_image = extract_box_reference(reference, *best);
75+
const auto exact_image = extract_box_reference(reference, *largest_object);
7676
cout << "Build waterfil template matcher from " << full_path << ", W x H: " << exact_image.width()
77-
<< " x " << exact_image.height() << ", area ratio: " << m_area_ratio << ", Object area: " << best->area << endl;
77+
<< " x " << exact_image.height() << ", area ratio: " << m_area_ratio << ", Object area: "
78+
<< largest_object->area << endl;
7879
dump_debug_image(
7980
global_logger_command_line(),
8081
"CommonFramework/WaterfillTemplateMatcher",

SerialPrograms/Source/CommonTools/ImageMatch/WaterfillTemplateMatcher.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ class WaterfillTemplateMatcher{
2828

2929

3030
public:
31-
// Load a template image from disk, min_color and max_color denote the color range of the object
32-
// displayed in the image file while min_area is the minimum number of pixels required for the
33-
// object in the template to be loaded.
31+
// Load a template image from disk, use waterfill to find the biggest object in the template image that
32+
// matches the color range of min_color and max_color.
33+
// min_area is the minimum number of pixels required for the found object in the template.
3434
//
35-
// The portion of the image holding the found object will get cropped and saved as the actual template image.
35+
// The portion of the image holding the biggest object will get cropped and saved as the actual template
36+
// image.
3637
// So if someone changes the template image by padding it to make it larger, as long as the padded color
3738
// does not fall into [min_color and max_color] range, it will not affect the template matching outcome
3839
// in any way.
@@ -49,6 +50,7 @@ class WaterfillTemplateMatcher{
4950
// Compute RMSD of the current image against the template as-is, using `ExactImageMatcher`.
5051
// `ExactImageMatcher` will resize the image to match template size and scale template brightness to match the image
5152
// before computing RMSD.
53+
// The part of the image template where alpha is 0 is not used to compare with the corresponding part in the input image.
5254
// In case the image is invalid, return a large value.
5355
// It also calls the virtual function `check_image()` on the image.
5456
// If the function returns false, then return a large value.
@@ -59,7 +61,8 @@ class WaterfillTemplateMatcher{
5961
// This cropped image is compared against the template as-is.
6062
// The waterfill object's aspect ratio and area ratio are checked against template's. Return a large value
6163
// if the check fails.
62-
// See `double rmsd(const ImageViewRGB32& image) const` on the details of comparing the image against the template.
64+
// See `double rmsd(Resolution input_resolution, const ImageViewRGB32& image) const` on the details of comparing the
65+
// image against the template.
6366
virtual double rmsd_precropped(
6467
Resolution input_resolution,
6568
const ImageViewRGB32& cropped_image,
@@ -71,7 +74,8 @@ class WaterfillTemplateMatcher{
7174
// image against the template as-is.
7275
// The waterfill object's aspect ratio and area ratio are checked against template's. Return a large value
7376
// if the check fails.
74-
// See `double rmsd(const ImageViewRGB32& image) const` on the details of comparing the image against the template.
77+
// See `double rmsd(Resolution input_resolution, const ImageViewRGB32& image) const` on the details of comparing the
78+
// image against the template.
7579
virtual double rmsd_original(
7680
Resolution input_resolution,
7781
const ImageViewRGB32& original_image,

0 commit comments

Comments
 (0)