本文整理汇总了C++中Mask2DCPtr::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ Mask2DCPtr::Value方法的具体用法?C++ Mask2DCPtr::Value怎么用?C++ Mask2DCPtr::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mask2DCPtr
的用法示例。
在下文中一共展示了Mask2DCPtr::Value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
}
示例2: calculateOpenings
void Morphology::calculateOpenings(Mask2DCPtr mask, int **values)
{
for(size_t y=0;y<mask->Height();++y)
{
size_t length = 0;
for(size_t x=0;x<mask->Width();++x)
{
if(mask->Value(x, y))
{
++length;
} else if(length > 0) {
for(size_t i=x-length;i<x;++i)
{
values[y][i] = length;
}
length = 0;
values[y][x] = 0;
} else {
values[y][x] = 0;
}
}
if(length > 0) {
for(size_t i=mask->Width()-length;i<mask->Width();++i)
{
values[y][i] = length;
}
}
}
for(size_t x=0;x<mask->Width();++x)
{
size_t length = 0;
for(size_t y=0;y<mask->Height();++y)
{
if(mask->Value(x, y))
{
++length;
} else if(length > 0) {
for(size_t i=y-length;i<y;++i)
{
if(values[i][x] < (int) length)
values[i][x] = -(int) length;
}
length = 0;
}
}
if(length > 0) {
for(size_t i=mask->Height()-length;i<mask->Height();++i)
{
if(values[i][x] < (int) length)
values[i][x] = -(int) length;
}
}
}
}
示例3: 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);
}
示例4: Write
void Compress::Write(std::ofstream &stream, Image2DCPtr image, Mask2DCPtr mask)
{
const num_t
max = ThresholdTools::MaxValue(image, mask),
min = ThresholdTools::MinValue(image, mask),
mid = (min + max) / 2.0;
const num_t normalizeFactor = (num_t) ((2<<22) + ((2<<22)-1)) / (max - min);
const uint32_t
width = image->Width(),
height = image->Height();
const char mode = 0;
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));
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) - mid) * normalizeFactor);
stream.write(reinterpret_cast<char*>(&value)+1, 3);
}
}
}
}
示例5: calculateVerticalCounts
void Morphology::calculateVerticalCounts(Mask2DCPtr mask, int **values)
{
for(size_t x=0;x<mask->Width();++x)
{
size_t length = 0;
for(size_t y=0;y<mask->Height();++y)
{
if(mask->Value(x, y))
{
++length;
} else if(length > 0) {
for(size_t i=y-length;i<y;++i)
{
values[i][x] = length;
}
length = 0;
values[y][x] = 0;
} else {
values[y][x] = 0;
}
}
for(size_t i=mask->Height()-length;i<mask->Height();++i)
{
values[i][x] = length;
}
}
}
示例6: ReadAllBeamlets
std::pair<TimeFrequencyData,TimeFrequencyMetaDataPtr> RSPReader::ReadSingleBeamlet(unsigned long timestepStart, unsigned long timestepEnd, unsigned beamletCount, unsigned beamletIndex)
{
std::pair<TimeFrequencyData,TimeFrequencyMetaDataPtr> data = ReadAllBeamlets(timestepStart, timestepEnd, beamletCount);
const unsigned width = timestepEnd - timestepStart;
Image2DPtr realX = Image2D::CreateZeroImagePtr(width, 1);
Image2DPtr imaginaryX = Image2D::CreateZeroImagePtr(width, 1);
Image2DPtr realY = Image2D::CreateZeroImagePtr(width, 1);
Image2DPtr imaginaryY = Image2D::CreateZeroImagePtr(width, 1);
Mask2DPtr mask = Mask2D::CreateUnsetMaskPtr(width, 1);
TimeFrequencyData allX = data.first.Make(Polarization::XX);
TimeFrequencyData allY = data.first.Make(Polarization::YY);
Image2DCPtr xr = allX.GetRealPart();
Image2DCPtr xi = allX.GetImaginaryPart();
Image2DCPtr yr = allY.GetRealPart();
Image2DCPtr yi = allY.GetImaginaryPart();
Mask2DCPtr maskWithBeamlets = data.first.GetSingleMask();
for(unsigned x=0;x<width;++x)
{
realX->SetValue(x, 0, xr->Value(x, beamletIndex));
imaginaryX->SetValue(x, 0, xi->Value(x, beamletIndex));
realY->SetValue(x, 0, yr->Value(x, beamletIndex));
imaginaryY->SetValue(x, 0, yi->Value(x, beamletIndex));
mask->SetValue(x, 0, maskWithBeamlets->Value(x, beamletIndex));
}
data.first = TimeFrequencyData(Polarization::XX, realX, imaginaryX, Polarization::YY, realY, imaginaryY);
data.first.SetGlobalMask(mask);
BandInfo band = data.second->Band();
band.channels[0] = data.second->Band().channels[beamletIndex];
band.channels.resize(1);
data.second->SetBand(band);
return data;
}
示例7: SegmentByMaxLength
void Morphology::SegmentByMaxLength(Mask2DCPtr mask, SegmentedImagePtr output)
{
int **lengthWidthValues = new int*[mask->Height()];
for(size_t y=0;y<mask->Height();++y)
lengthWidthValues[y] = new int[mask->Width()];
calculateOpenings(mask, lengthWidthValues);
for(size_t y=0;y<mask->Height();++y)
{
for(size_t x=0;x<mask->Width();++x)
output->SetValue(x,y,0);
}
for(size_t y=0;y<mask->Height();++y)
{
for(size_t x=0;x<mask->Width();++x)
{
if(mask->Value(x, y) && output->Value(x,y) == 0)
{
floodFill(mask, output, lengthWidthValues, x, y, output->NewSegmentValue());
}
}
}
for(size_t y=0;y<mask->Height();++y)
delete[] lengthWidthValues[y];
delete[] lengthWidthValues;
}
示例8: Add
void FrequencyFlagCountPlot::Add(class TimeFrequencyData &data, TimeFrequencyMetaDataCPtr meta)
{
_ignoreFirstChannel = _ignoreFirstChannel && data.ImageHeight() != 1;
size_t yStart = _ignoreFirstChannel ? 1 : 0;
for(size_t maskIndex=0;maskIndex<data.MaskCount();++maskIndex)
{
Mask2DCPtr mask = data.GetMask(maskIndex);
for(size_t y=yStart;y<mask->Height();++y)
{
double frequency = meta->Band().channels[y].frequencyHz;
size_t count = 0;
for(size_t x=0;x<mask->Width();++x)
{
if(mask->Value(x, y))
++count;
}
MapItem item = _counts[frequency];
item.count += count;
item.total += mask->Width();
_counts[frequency] = item;
}
}
}
示例9: MaskToInts
void StatisticalFlagger::MaskToInts(Mask2DCPtr mask, int **maskAsInt)
{
for(size_t y=0;y<mask->Height();++y)
{
int *column = maskAsInt[y];
for(size_t x=0;x<mask->Width();++x)
{
column[x] = mask->Value(x, y) ? 1 : 0;
}
}
}
示例10: 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;
}
示例11: Image
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;
}
}
}
示例12: Perform
void ImagerAction::Perform(ArtifactSet &artifacts, ProgressListener &progress)
{
boost::mutex::scoped_lock lock(_imagerMutex);
UVImager *imager = artifacts.Imager();
if(imager == 0)
throw BadUsageException("No imager available to create image.");
TimeFrequencyData &data = artifacts.ContaminatedData();
TimeFrequencyMetaDataCPtr metaData = artifacts.MetaData();
if(data.PolarisationCount() > 1)
{
TimeFrequencyData *tmp = data.CreateTFData(StokesIPolarisation);
data = *tmp;
delete tmp;
}
bool btPlaneImager = true;
if(btPlaneImager)
{
typedef double ImagerNumeric;
BaselineTimePlaneImager<ImagerNumeric> btImager;
BandInfo band = metaData->Band();
Image2DCPtr
inputReal = data.GetRealPart(),
inputImag = data.GetImaginaryPart();
Mask2DCPtr mask = data.GetSingleMask();
size_t width = inputReal->Width();
for(size_t t=0;t!=width;++t)
{
UVW uvw = metaData->UVW()[t];
size_t channelCount = inputReal->Height();
std::vector<std::complex<ImagerNumeric> > data(channelCount);
for(size_t ch=0;ch!=channelCount;++ch) {
if(mask->Value(t, ch))
data[ch] = std::complex<ImagerNumeric>(0.0, 0.0);
else
data[ch] = std::complex<ImagerNumeric>(inputReal->Value(t, ch), inputImag->Value(t, ch));
}
btImager.Image(uvw.u, uvw.v, uvw.w, band.channels[0].frequencyHz, band.channels[1].frequencyHz-band.channels[0].frequencyHz, channelCount, &(data[0]), imager->FTReal());
}
} else {
progress.OnStartTask(*this, 0, 1, "Imaging baseline");
for(size_t y=0;y<data.ImageHeight();++y)
{
imager->Image(data, metaData, y);
progress.OnProgress(*this, y, data.ImageHeight());
}
progress.OnEndTask(*this);
}
}
示例13:
void Mask2D::EnlargeHorizontallyAndSet(Mask2DCPtr smallMask, int factor)
{
for(size_t x=0;x<smallMask->Width();++x)
{
size_t binSize = factor;
if(binSize + x*factor > _width)
binSize = _width - x*factor;
for(size_t y=0;y<_height;++y)
{
for(size_t binX=0;binX<binSize;++binX)
{
size_t curX = x*factor + binX;
SetValue(curX, y, smallMask->Value(x, y));
}
}
}
}
示例14: 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);
}
}
}
}
示例15: 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);
}
}
}
}