本文整理汇总了C++中Mask2DPtr::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ Mask2DPtr::Value方法的具体用法?C++ Mask2DPtr::Value怎么用?C++ Mask2DPtr::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mask2DPtr
的用法示例。
在下文中一共展示了Mask2DPtr::Value方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LineRemover
void StatisticalFlagger::LineRemover(Mask2DPtr mask, size_t maxTimeContamination, size_t maxFreqContamination)
{
for(size_t x=0;x<mask->Width();++x)
{
size_t count = 0;
for(size_t y=0;y<mask->Height();++y)
{
if(mask->Value(x,y))
++count;
}
if(count > maxFreqContamination)
FlagTime(mask, x);
}
for(size_t y=0;y<mask->Height();++y)
{
size_t count = 0;
for(size_t x=0;x<mask->Width();++x)
{
if(mask->Value(x,y))
++count;
}
if(count > maxTimeContamination)
FlagFrequency(mask, y);
}
}
示例2: floodFill
void Morphology::floodFill(Mask2DCPtr mask, SegmentedImagePtr output, Mask2DPtr *matrices, size_t x, size_t y, size_t z, size_t value, int **hCounts, int **vCounts)
{
std::stack<MorphologyPoint3D> points;
MorphologyPoint3D startPoint;
startPoint.x = x;
startPoint.y = y;
startPoint.z = z;
points.push(startPoint);
do {
MorphologyPoint3D p = points.top();
points.pop();
if(mask->Value(p.x, p.y))
{
if(output->Value(p.x, p.y) == 0)
{
output->SetValue(p.x, p.y, value);
} else {
// now we need to decide whether to change this sample to the new segment or not
if(hCounts[p.y][p.x] < vCounts[p.y][p.x] && p.z == 2)
output->SetValue(p.x, p.y, value);
}
}
Mask2DPtr matrix = matrices[p.z];
matrix->SetValue(p.x, p.y, false);
if((p.z == 0 || p.z == 2) && matrices[1]->Value(p.x,p.y))
{
MorphologyPoint3D newP;
newP.x = p.x; newP.y = p.y; newP.z = 1;
points.push(newP);
}
if(p.x > 0 && matrix->Value(p.x-1,p.y))
{
MorphologyPoint3D newP;
newP.x = p.x-1; newP.y = p.y; newP.z = p.z;
points.push(newP);
}
if(p.x < mask->Width()-1 && matrix->Value(p.x+1,p.y))
{
MorphologyPoint3D newP;
newP.x = p.x+1; newP.y = p.y; newP.z = p.z; newP.z = p.z;
points.push(newP);
}
if(p.y > 0 && matrix->Value(p.x,p.y-1))
{
MorphologyPoint3D newP;
newP.x = p.x; newP.y = p.y-1; newP.z = p.z;
points.push(newP);
}
if(p.y < mask->Height()-1 && matrix->Value(p.x,p.y+1))
{
MorphologyPoint3D newP;
newP.x = p.x; newP.y = p.y+1; newP.z = p.z;
points.push(newP);
}
} while(points.size() != 0);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
}
示例6: LineThreshold
void ImageTile::LineThreshold(bool evaluateBaseline, long double mean, long double variance, bool convolve)
{
Image2DPtr input = Image2D::CreateEmptyImagePtr(_scanCount, _channelCount);
Mask2DPtr output = Mask2D::CreateSetMaskPtr<false>(_scanCount, _channelCount);
if(evaluateBaseline) {
for(unsigned channel = 0;channel<_channelCount;++channel)
for(unsigned scan = 0;scan<_scanCount;++scan)
input->SetValue(scan, channel, GetValueAt(channel, scan) - EvaluateBaselineFunction(scan, channel));
} else {
for(unsigned channel = 0;channel<_channelCount;++channel)
for(unsigned scan = 0;scan<_scanCount;++scan)
input->SetValue(scan, channel, GetValueAt(channel, scan) - mean);
}
ThresholdMitigater::SumThreshold(input, output, 1, _trigger * variance);
ThresholdMitigater::SumThreshold(input, output, 2, _trigger * variance * 1.6);
ThresholdMitigater::SumThreshold(input, output, 3, _trigger * variance * 2.2);
ThresholdMitigater::SumThreshold(input, output, 5, _trigger * variance * 3.0);
ThresholdMitigater::SumThreshold(input, output, 10, _trigger * variance * 5.0);
unsigned count = 0;
for(unsigned channel = 0;channel<_channelCount;++channel) {
for(unsigned scan = 0;scan<_scanCount;++scan) {
if(output->Value(scan, channel)) {
Window(scan, channel);
count++;
}
}
}
while(count*2 > _channelCount*_scanCount) {
size_t x = (size_t) (RNG::Uniform()*_scanCount);
size_t y = (size_t) (RNG::Uniform()*_channelCount);
if(_isWindowed[y][x]) {
count--;
_isWindowed[y][x]=false;
}
}
if(convolve)
ConvolveWindows();
}
示例7: VerticalSumThreshold
void ThresholdMitigater::VerticalSumThreshold(Image2DCPtr input, Mask2DPtr mask, num_t threshold)
{
if(Length <= input->Height())
{
size_t height = input->Height()-Length+1;
for(size_t y=0;y<height;++y) {
for(size_t x=0;x<input->Width();++x) {
num_t sum = 0.0;
size_t count = 0;
for(size_t i=0;i<Length;++i) {
if(!mask->Value(x, y+i)) {
sum += input->Value(x, y + i);
count++;
}
}
if(count>0 && fabs(sum/count) > threshold) {
for(size_t i=0;i<Length;++i)
mask->SetValue(x, y + i, true);
}
}
}
}
}
示例8: update
void ImageWidget::update(Cairo::RefPtr<Cairo::Context> cairo, unsigned width, unsigned height)
{
Image2DCPtr image = _image;
Mask2DCPtr mask = GetActiveMask(), originalMask = _originalMask, alternativeMask = _alternativeMask;
unsigned int
startX = (unsigned int) round(_startHorizontal * image->Width()),
startY = (unsigned int) round(_startVertical * image->Height()),
endX = (unsigned int) round(_endHorizontal * image->Width()),
endY = (unsigned int) round(_endVertical * image->Height());
size_t
imageWidth = endX - startX,
imageHeight = endY - startY;
if(imageWidth > 30000)
{
int shrinkFactor = (imageWidth + 29999) / 30000;
image = image->ShrinkHorizontally(shrinkFactor);
mask = mask->ShrinkHorizontally(shrinkFactor);
if(originalMask != 0)
originalMask = originalMask->ShrinkHorizontally(shrinkFactor);
if(alternativeMask != 0)
alternativeMask = alternativeMask->ShrinkHorizontally(shrinkFactor);
startX /= shrinkFactor;
endX /= shrinkFactor;
imageWidth = endX - startX;
}
num_t min, max;
findMinMax(image, mask, min, max);
// If these are not yet created, they are 0, so ok to delete.
delete _horiScale;
delete _vertScale;
delete _colorScale;
delete _plotTitle;
if(_showXYAxes)
{
_vertScale = new VerticalPlotScale();
_vertScale->SetDrawWithDescription(_showYAxisDescription);
_horiScale = new HorizontalPlotScale();
_horiScale->SetDrawWithDescription(_showXAxisDescription);
} else {
_vertScale = 0;
_horiScale = 0;
}
if(_showColorScale)
{
_colorScale = new ColorScale();
_colorScale->SetDrawWithDescription(_showZAxisDescription);
} else {
_colorScale = 0;
}
if(_showXYAxes)
{
if(_metaData != 0 && _metaData->HasBand()) {
_vertScale->InitializeNumericTicks(_metaData->Band().channels[startY].frequencyHz / 1e6, _metaData->Band().channels[endY-1].frequencyHz / 1e6);
_vertScale->SetUnitsCaption("Frequency (MHz)");
} else {
_vertScale->InitializeNumericTicks(-0.5 + startY, 0.5 + endY - 1.0);
}
if(_metaData != 0 && _metaData->HasObservationTimes())
{
_horiScale->InitializeTimeTicks(_metaData->ObservationTimes()[startX], _metaData->ObservationTimes()[endX-1]);
_horiScale->SetUnitsCaption("Time");
} else {
_horiScale->InitializeNumericTicks(-0.5 + startX, 0.5 + endX - 1.0);
}
if(_manualXAxisDescription)
_horiScale->SetUnitsCaption(_xAxisDescription);
if(_manualYAxisDescription)
_vertScale->SetUnitsCaption(_yAxisDescription);
}
if(_metaData != 0) {
if(_showColorScale && _metaData->ValueDescription()!="")
{
if(_metaData->ValueUnits()!="")
_colorScale->SetUnitsCaption(_metaData->ValueDescription() + " (" + _metaData->ValueUnits() + ")");
else
_colorScale->SetUnitsCaption(_metaData->ValueDescription());
}
}
if(_showColorScale)
{
if(_scaleOption == LogScale)
_colorScale->InitializeLogarithmicTicks(min, max);
else
_colorScale->InitializeNumericTicks(min, max);
if(_manualZAxisDescription)
_colorScale->SetUnitsCaption(_zAxisDescription);
}
if(_showTitle && !actualTitleText().empty())
{
_plotTitle = new Title();
_plotTitle->SetText(actualTitleText());
_plotTitle->SetPlotDimensions(width, height, 0.0);
_topBorderSize = _plotTitle->GetHeight(cairo);
} else {
//.........这里部分代码省略.........