本文整理汇总了C++中Mask2DPtr::Swap方法的典型用法代码示例。如果您正苦于以下问题:C++ Mask2DPtr::Swap方法的具体用法?C++ Mask2DPtr::Swap怎么用?C++ Mask2DPtr::Swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mask2DPtr
的用法示例。
在下文中一共展示了Mask2DPtr::Swap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VerticalSumThresholdLarge
void ThresholdMitigater::VerticalSumThresholdLarge(Image2DCPtr input, Mask2DPtr mask, num_t threshold)
{
Mask2DPtr maskCopy = Mask2D::CreateCopy(mask);
const size_t width = mask->Width(), height = mask->Height();
if(Length <= height)
{
for(size_t x=0;x<width;++x)
{
num_t sum = 0.0;
size_t count = 0, yTop, yBottom;
for(yBottom=0;yBottom<Length-1;++yBottom)
{
if(!mask->Value(x, yBottom))
{
sum += input->Value(x, yBottom);
++count;
}
}
yTop = 0;
while(yBottom < height)
{
// add the sample at the bottom
if(!mask->Value(x, yBottom))
{
sum += input->Value(x, yBottom);
++count;
}
// Check
if(count>0 && fabs(sum/count) > threshold)
{
for(size_t i=0;i<Length;++i)
maskCopy->SetValue(x, yTop + i, true);
}
// subtract the sample at the top
if(!mask->Value(x, yTop))
{
sum -= input->Value(x, yTop);
--count;
}
++yTop;
++yBottom;
}
}
}
mask->Swap(maskCopy);
}
示例2: HorizontalSumThresholdLarge
void ThresholdMitigater::HorizontalSumThresholdLarge(Image2DCPtr input, Mask2DPtr mask, num_t threshold)
{
Mask2DPtr maskCopy = Mask2D::CreateCopy(mask);
const size_t width = mask->Width(), height = mask->Height();
if(Length <= width)
{
for(size_t y=0;y<height;++y)
{
num_t sum = 0.0;
size_t count = 0, xLeft, xRight;
for(xRight=0;xRight<Length-1;++xRight)
{
if(!mask->Value(xRight, y))
{
sum += input->Value(xRight, y);
count++;
}
}
xLeft = 0;
while(xRight < width)
{
// add the sample at the right
if(!mask->Value(xRight, y))
{
sum += input->Value(xRight, y);
++count;
}
// Check
if(count>0 && fabs(sum/count) > threshold)
{
maskCopy->SetHorizontalValues(xLeft, y, true, Length);
}
// subtract the sample at the left
if(!mask->Value(xLeft, y))
{
sum -= input->Value(xLeft, y);
--count;
}
++xLeft;
++xRight;
}
}
}
mask->Swap(maskCopy);
}
示例3: DilateFlagsHorizontally
void StatisticalFlagger::DilateFlagsHorizontally(Mask2DPtr mask, size_t timeSize)
{
if(timeSize != 0)
{
Mask2DPtr destination = Mask2D::CreateUnsetMaskPtr(mask->Width(), mask->Height());
if(timeSize > mask->Width()) timeSize = mask->Width();
const int intSize = (int) timeSize;
for(size_t y=0;y<mask->Height();++y)
{
int dist = intSize + 1;
for(size_t x=0;x<timeSize;++x)
{
if(mask->Value(x, y))
dist = - intSize;
dist++;
}
for(size_t x=0;x<mask->Width() - timeSize;++x)
{
if(mask->Value(x + timeSize, y))
dist = -intSize;
if(dist <= intSize)
{
destination->SetValue(x, y, true);
dist++;
} else {
destination->SetValue(x, y, false);
}
}
for(size_t x=mask->Width() - timeSize;x<mask->Width();++x)
{
if(dist <= intSize)
{
destination->SetValue(x, y, true);
dist++;
} else {
destination->SetValue(x, y, false);
}
}
}
mask->Swap(destination);
}
}