Skip to content

Commit

Permalink
check for mask in a region instead of a single point
Browse files Browse the repository at this point in the history
  • Loading branch information
servantftechnicolor committed Oct 29, 2024
1 parent 396d82c commit f3d2497
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/aliceVision/featureEngine/FeatureExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ void FeatureExtractor::computeViewJob(const FeatureExtractorViewJob& job, bool u
double pixelRatio = 1.0;
job.view().getImage().getDoubleMetadata({"PixelAspectRatio"}, pixelRatio);

std::array<Vec2, 5> shifts;
shifts[0] = Vec2(-1, 0);
shifts[1] = Vec2(1, 0);
shifts[2] = Vec2(0, -1);
shifts[3] = Vec2(0, 1);
shifts[4] = Vec2(0, 0);

if (pixelRatio != 1.0)
{
// Resample input image in order to work with square pixels
Expand Down Expand Up @@ -265,9 +272,8 @@ void FeatureExtractor::computeViewJob(const FeatureExtractorViewJob& job, bool u
for (size_t i = 0, n = regions->RegionCount(); i != n; ++i)
{
const Vec2 position = regions->GetRegionPosition(i);
const int x = int(position.x());
const int y = int(position.y());




bool masked = false;

Expand All @@ -276,12 +282,23 @@ void FeatureExtractor::computeViewJob(const FeatureExtractorViewJob& job, bool u
{
masked = true;
}
//Check if the optional image mask tells us to ignore this coordinate
else if (x < mask.width() && y < mask.height())
else
{
if ((mask(y, x) == 0 && !_maskInvert) || (mask(y, x) != 0 && _maskInvert))
//Check if the optional image mask tells us to ignore this coordinate
for (int idx = 0; idx < shifts.size(); idx++)
{
masked = true;
const double scale = regions->Features()[i].scale();
const Vec2 npos = position + scale * shifts[idx];
const int x = int(npos.x());
const int y = int(npos.y());

if (x >= 0 && y >= 0 && x < mask.width() && y < mask.height())
{
if ((mask(y, x) == 0 && !_maskInvert) || (mask(y, x) != 0 && _maskInvert))
{
masked = true;
}
}
}
}

Expand Down

0 comments on commit f3d2497

Please sign in to comment.