Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Sep 22, 2024
1 parent b2e56df commit 284d075
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nQuantGpp/Otsu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ namespace OtsuThreshold
thresh = 200;
}

auto minThresh = (uchar)(thresh * weight);
auto minThresh = (uchar)(thresh * (m_transparentPixelIndex >= 0 ? .9f : weight));
for (uint y = 0; y < pixels.rows; ++y)
{
for (uint x = 0; x < pixels.cols; ++x)
{
auto& d = dest(y, x);
const auto& c = pixels(y, x);

if (m_transparentPixelIndex >= 0 && c[2] + c[1] + c[0] > maxThresh * 3)
if (c[3] < alphaThreshold && c[2] + c[1] + c[0] > maxThresh * 3)
d = Vec4b(UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, c[3]);
else if (m_transparentPixelIndex >= 0 || c[2] + c[1] + c[0] < minThresh * 3)
else if (c[2] + c[1] + c[0] < minThresh * 3)
d = Vec4b(0, 0, 0, c[3]);
}
}
Expand Down

0 comments on commit 284d075

Please sign in to comment.