本文整理汇总了C++中Mask2DCPtr类的典型用法代码示例。如果您正苦于以下问题:C++ Mask2DCPtr类的具体用法?C++ Mask2DCPtr怎么用?C++ Mask2DCPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mask2DCPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Mask2D::EnlargeVerticallyAndSet(Mask2DCPtr smallMask, int factor)
{
for(size_t y=0;y<smallMask->Height();++y)
{
size_t binSize = factor;
if(binSize + y*factor > _height)
binSize = _height - y*factor;
for(size_t x=0;x<_width;++x)
{
for(size_t binY=0;binY<binSize;++binY)
{
size_t curY = y*factor + binY;
SetValue(x, curY, smallMask->Value(x, y));
}
}
}
}
示例2: ThresholdTime
void StatisticalFlagger::ThresholdTime(Mask2DCPtr mask, int **flagMarks, int **sums, int thresholdLevel, int width)
{
int halfWidthL = (width-1) / 2;
int halfWidthR = (width-1) / 2;
for(size_t y=0;y<mask->Height();++y)
{
const int *column = sums[y];
for(size_t x=halfWidthL;x<mask->Width() - halfWidthR;++x)
{
if(column[x] > thresholdLevel)
{
const unsigned right = x+halfWidthR+1;
++flagMarks[y][x-halfWidthL];
if(right < mask->Width())
--flagMarks[y][right];
}
}
}
}
示例3: ThresholdFrequency
void StatisticalFlagger::ThresholdFrequency(Mask2DCPtr mask, int **flagMarks, int **sums, int thresholdLevel, int width)
{
int halfWidthT = (width-1) / 2;
int halfWidthB = (width-1) / 2;
for(size_t y=halfWidthT;y<mask->Height() - halfWidthB;++y)
{
int *column = sums[y];
for(size_t x=0;x<mask->Width();++x)
{
if(column[x] > thresholdLevel)
{
const unsigned bottom = y+halfWidthB+1;
++flagMarks[y-halfWidthT][x];
if(bottom < mask->Height())
--flagMarks[bottom][x];
}
}
}
}
示例4: SquareContainsFlag
bool StatisticalFlagger::SquareContainsFlag(Mask2DCPtr mask, size_t xLeft, size_t yTop, size_t xRight, size_t yBottom)
{
for(size_t y=yTop;y<=yBottom;++y)
{
for(size_t x=xLeft;x<=xRight;++x)
{
if(mask->Value(x, y))
return true;
}
}
return false;
}
示例5: SumToTop
void StatisticalFlagger::SumToTop(Mask2DCPtr mask, int **sums, size_t width, size_t step, bool reverse)
{
if(reverse)
{
for(size_t y=width;y<mask->Height();++y)
{
int *column = sums[y];
for(size_t x=0;x<mask->Width();++x)
{
if(mask->Value(x, y - width/2))
column[x] += step;
}
}
} else {
for(size_t y=0;y<mask->Height() - width;++y)
{
int *column = sums[y];
for(size_t x=0;x<mask->Width();++x)
{
if(mask->Value(x, y + width/2))
column[x] += step;
}
}
}
}
示例6: DecreaseTimeWithMask
void ChangeResolutionAction::DecreaseTimeWithMask(TimeFrequencyData &data)
{
size_t polCount = data.PolarisationCount();
for(size_t i=0;i<polCount;++i)
{
TimeFrequencyData *polData = data.CreateTFDataFromPolarisationIndex(i);
Mask2DCPtr mask = polData->GetSingleMask();
for(unsigned j=0;j<polData->ImageCount();++j)
{
Image2DCPtr image = polData->GetImage(j);
polData->SetImage(j, ThresholdTools::ShrinkHorizontally(_timeDecreaseFactor, image, mask));
}
delete polData;
}
size_t maskCount = data.MaskCount();
for(size_t i=0;i<maskCount;++i)
{
Mask2DCPtr mask = data.GetMask(i);
Mask2DPtr newMask = mask->ShrinkHorizontallyForAveraging(_timeDecreaseFactor);
data.SetMask(i, newMask);
}
}
示例7: Empty
void UVImager::Image(const TimeFrequencyData &data, TimeFrequencyMetaDataCPtr metaData, unsigned frequencyIndex)
{
if(_uvReal == 0)
Empty();
Image2DCPtr
real = data.GetRealPart(),
imaginary = data.GetImaginaryPart();
Mask2DCPtr
flags = data.GetSingleMask();
for(unsigned i=0;i<data.ImageWidth();++i) {
switch(_imageKind) {
case Homogeneous:
if(flags->Value(i, frequencyIndex)==0.0L) {
num_t
vr = real->Value(i, frequencyIndex),
vi = imaginary->Value(i, frequencyIndex);
if(std::isfinite(vr) && std::isfinite(vi))
{
num_t u,v;
GetUVPosition(u, v, i, frequencyIndex, metaData);
SetUVValue(u, v, vr, vi, 1.0);
SetUVValue(-u, -v, vr, -vi, 1.0);
}
}
break;
case Flagging:
if((flags->Value(i, frequencyIndex)!=0.0L && !_invertFlagging) ||
(flags->Value(i, frequencyIndex)==0.0L && _invertFlagging)) {
num_t u,v;
GetUVPosition(u, v, i, frequencyIndex, metaData);
SetUVValue(u, v, 1, 0, 1.0);
SetUVValue(-u, -v, 1, 0, 1.0);
}
break;
}
}
}
示例8: polData
void ChangeResolutionAction::DecreaseTimeWithMask(TimeFrequencyData& data)
{
size_t polCount = data.PolarizationCount();
for(size_t i=0;i<polCount;++i)
{
TimeFrequencyData polData(data.MakeFromPolarizationIndex(i));
const Mask2DCPtr mask = polData.GetSingleMask();
for(unsigned j=0;j<polData.ImageCount();++j)
{
const Image2DCPtr image = polData.GetImage(j);
polData.SetImage(j, ThresholdTools::ShrinkHorizontally(_timeDecreaseFactor, image.get(), mask.get()));
}
data.SetPolarizationData(i, std::move(polData));
}
size_t maskCount = data.MaskCount();
for(size_t i=0;i<maskCount;++i)
{
Mask2DCPtr mask = data.GetMask(i);
Mask2DPtr newMask(new Mask2D(mask->ShrinkHorizontallyForAveraging(_timeDecreaseFactor)));
data.SetMask(i, std::move(newMask));
}
}
示例9: Add
void FrequencyPowerPlot::Add(class TimeFrequencyData &data, TimeFrequencyMetaDataCPtr meta)
{
Image2DCPtr image = data.GetSingleImage();
Mask2DCPtr mask = data.GetSingleMask();
for(size_t y=0;y<image->Height();++y)
{
double frequency = meta->Band().channels[y].frequencyHz;
size_t count = 0;
long double value = 0.0L;
for(size_t x=0;x<image->Width();++x)
{
if(!mask->Value(x, y))
{
++count;
value += image->Value(x, y);
}
}
MapItem &item = _values[frequency];
item.total += value;
item.count += count;
}
}
示例10: DecreaseTimeWithMask
void ChangeResolutionAction::DecreaseTime(TimeFrequencyData &timeFrequencyData)
{
if(_useMaskInAveraging)
{
DecreaseTimeWithMask(timeFrequencyData);
}
else {
size_t imageCount = timeFrequencyData.ImageCount();
for(size_t i=0;i<imageCount;++i)
{
Image2DCPtr image = timeFrequencyData.GetImage(i);
Image2DPtr newImage(new Image2D(image->ShrinkHorizontally(_timeDecreaseFactor)));
timeFrequencyData.SetImage(i, std::move(newImage));
}
size_t maskCount = timeFrequencyData.MaskCount();
for(size_t i=0;i<maskCount;++i)
{
Mask2DCPtr mask = timeFrequencyData.GetMask(i);
Mask2DPtr newMask(new Mask2D(mask->ShrinkHorizontally(_timeDecreaseFactor)));
timeFrequencyData.SetMask(i, std::move(newMask));
}
}
}
示例11: floodFill
void Morphology::floodFill(Mask2DCPtr mask, SegmentedImagePtr output, const int *const *lengthWidthValues, size_t x, size_t y, size_t value)
{
std::stack<MorphologyPoint2D> points;
MorphologyPoint2D startPoint;
startPoint.x = x;
startPoint.y = y;
points.push(startPoint);
do {
MorphologyPoint2D p = points.top();
points.pop();
output->SetValue(p.x, p.y, value);
int z = lengthWidthValues[p.y][p.x];
if(p.x > 0 && output->Value(p.x-1, p.y) == 0 && mask->Value(p.x-1,p.y))
{
int zl = lengthWidthValues[p.y][p.x-1];
if((zl > 0 && z > 0) || (zl < 0 && z < 0))
{
MorphologyPoint2D newP;
newP.x = p.x-1; newP.y = p.y;
points.push(newP);
}
}
if(p.x < mask->Width()-1 && output->Value(p.x+1, p.y)==0 && mask->Value(p.x+1,p.y))
{
int zr = lengthWidthValues[p.y][p.x+1];
if((zr > 0 && z > 0) || (zr < 0 && z < 0))
{
MorphologyPoint2D newP;
newP.x = p.x+1; newP.y = p.y;
points.push(newP);
}
}
if(p.y > 0 && output->Value(p.x, p.y-1)==0 && mask->Value(p.x,p.y-1))
{
int zt = lengthWidthValues[p.y-1][p.x];
if((zt > 0 && z > 0) || (zt < 0 && z < 0))
{
MorphologyPoint2D newP;
newP.x = p.x; newP.y = p.y-1;
points.push(newP);
}
}
if(p.y < mask->Height()-1 && output->Value(p.x, p.y+1)==0 && mask->Value(p.x,p.y+1))
{
int zb = lengthWidthValues[p.y+1][p.x];
if((zb > 0 && z > 0) || (zb < 0 && z < 0))
{
MorphologyPoint2D newP;
newP.x = p.x; newP.y = p.y+1;
points.push(newP);
}
}
} while(points.size() != 0);
}
示例12: setFlaggedValuesToZeroAndMakeWeights
void HighPassFilter::setFlaggedValuesToZeroAndMakeWeights(const Image2DCPtr &inputImage, const Image2DPtr &outputImage, const Mask2DCPtr &inputMask, const Image2DPtr &weightsOutput)
{
const size_t width = inputImage->Width();
for(size_t y=0;y<inputImage->Height();++y)
{
for(size_t x=0;x<width;++x)
{
if(inputMask->Value(x, y) || !isfinite(inputImage->Value(x, y)))
{
outputImage->SetValue(x, y, 0.0);
weightsOutput->SetValue(x, y, 0.0);
} else {
outputImage->SetValue(x, y, inputImage->Value(x, y));
weightsOutput->SetValue(x, y, 1.0);
}
}
}
}
示例13: setFlaggedValuesToZeroAndMakeWeightsSSE
void HighPassFilter::setFlaggedValuesToZeroAndMakeWeightsSSE(const Image2DCPtr &inputImage, const Image2DPtr &outputImage, const Mask2DCPtr &inputMask, const Image2DPtr &weightsOutput)
{
const size_t width = inputImage->Width();
const __m128i zero4i = _mm_set_epi32(0, 0, 0, 0);
const __m128 zero4 = _mm_set_ps(0.0, 0.0, 0.0, 0.0);
const __m128 one4 = _mm_set_ps(1.0, 1.0, 1.0, 1.0);
for(size_t y=0;y<inputImage->Height();++y)
{
const bool *rowPtr = inputMask->ValuePtr(0, y);
const float *inputPtr = inputImage->ValuePtr(0, y);
float *outputPtr = outputImage->ValuePtr(0, y);
float *weightsPtr = weightsOutput->ValuePtr(0, y);
const float *end = inputPtr + width;
while(inputPtr < end)
{
// Assign each integer to one bool in the mask
// Convert false to 0xFFFFFFFF and true to 0
__m128 conditionMask = _mm_castsi128_ps(
_mm_cmpeq_epi32(_mm_set_epi32(rowPtr[3] || !isfinite(inputPtr[3]), rowPtr[2] || !isfinite(inputPtr[2]),
rowPtr[1] || !isfinite(inputPtr[1]), rowPtr[0] || !isfinite(inputPtr[0])),
zero4i));
_mm_store_ps(weightsPtr, _mm_or_ps(
_mm_and_ps(conditionMask, one4),
_mm_andnot_ps(conditionMask, zero4)
));
_mm_store_ps(outputPtr, _mm_or_ps(
_mm_and_ps(conditionMask, _mm_load_ps(inputPtr)),
_mm_andnot_ps(conditionMask, zero4)
));
rowPtr += 4;
outputPtr += 4;
inputPtr += 4;
weightsPtr += 4;
}
}
}
示例14: WriteSubtractFrequencies
void Compress::WriteSubtractFrequencies(std::ofstream &stream, Image2DCPtr image, Mask2DCPtr mask)
{
const num_t
max = ThresholdTools::MaxValue(image, mask),
min = ThresholdTools::MinValue(image, mask);
const num_t normalizeFactor = (num_t) ((2<<22) + ((2<<22)-1)) / (max - min);
//const num_t normalizeFactor = 256.0;
const uint32_t
width = image->Width(),
height = image->Height();
const char mode = 1;
stream.write(reinterpret_cast<const char*>(&max), sizeof(max));
stream.write(reinterpret_cast<const char*>(&min), sizeof(min));
stream.write(reinterpret_cast<const char*>(&width), sizeof(width));
stream.write(reinterpret_cast<const char*>(&height), sizeof(height));
stream.write(&mode, sizeof(mode));
std::vector<int32_t> basis(width);
for(size_t x=0;x<width;++x)
{
SampleRowPtr row = SampleRow::CreateFromColumn(image, x);
basis[x] = (int32_t) round(row->Median() * normalizeFactor);
}
stream.write(reinterpret_cast<char*>(&basis[0]), sizeof(basis));
for(unsigned y=0;y<height;++y)
{
for(unsigned x=0;x<width;++x)
{
if(!mask->Value(x, y))
{
int32_t value = (int32_t) (round(image->Value(x, y) * normalizeFactor) - basis[x]);
stream.write(reinterpret_cast<char*>(&value)+1, 3);
}
}
}
}
示例15: Read
Image2DPtr Compress::Read(std::ifstream &stream, Image2DPtr image, Mask2DCPtr mask)
{
num_t max = 0.0, min = 0.0;
size_t width = 0, height = 0;
char mode = 0;
stream.read(reinterpret_cast<char*>(&max), sizeof(max));
stream.read(reinterpret_cast<char*>(&min), sizeof(min));
stream.read(reinterpret_cast<char*>(&width), sizeof(width));
stream.read(reinterpret_cast<char*>(&height), sizeof(height));
stream.read(&mode, sizeof(mode));
num_t normalizeFactor = (max - min) / (num_t) ((2<<22) + ((2<<22)-1));
for(unsigned y=0;y<height;++y)
{
for(unsigned x=0;x<width;++x)
{
if(!mask->Value(x, y))
{
int32_t value;
stream.read(reinterpret_cast<char*>(&value), 3);
value >>= 8;
image->SetValue(x, y, value / normalizeFactor + min);
}
}
}