当前位置: 首页>>代码示例>>C++>>正文


C++ Mask2DPtr类代码示例

本文整理汇总了C++中Mask2DPtr的典型用法代码示例。如果您正苦于以下问题:C++ Mask2DPtr类的具体用法?C++ Mask2DPtr怎么用?C++ Mask2DPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mask2DPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newImage

	void ChangeResolutionAction::IncreaseFrequency(TimeFrequencyData &originalData, const TimeFrequencyData &changedData, bool restoreImage, bool restoreMask)
	{
		if(restoreImage)
		{
			size_t imageCount = originalData.ImageCount();
			if(imageCount != changedData.ImageCount())
				throw std::runtime_error("When restoring resolution in change resolution action, original data and changed data do not have the same number of images");
			for(size_t i=0;i<imageCount;++i)
			{
				Image2DCPtr image = changedData.GetImage(i);
				Image2DPtr newImage(new Image2D(image->EnlargeVertically(_frequencyDecreaseFactor, originalData.ImageHeight())));
				originalData.SetImage(i, newImage);
			}
		}
		if(restoreMask)
		{
			originalData.SetMask(changedData);
			size_t maskCount = originalData.MaskCount();
			for(size_t i=0;i<maskCount;++i)
			{
				Mask2DCPtr mask = changedData.GetMask(i);
				Mask2DPtr newMask = Mask2D::CreateUnsetMaskPtr(originalData.ImageWidth(), originalData.ImageHeight());
				newMask->EnlargeVerticallyAndSet(*mask, _frequencyDecreaseFactor);
				originalData.SetMask(i, newMask);
			}
		}
	}
开发者ID:kernsuite-debian,项目名称:aoflagger,代码行数:27,代码来源:changeresolutionaction.cpp

示例2: 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;
}
开发者ID:kernsuite-debian,项目名称:aoflagger,代码行数:35,代码来源:rspreader.cpp

示例3: FlagFrequency

void StatisticalFlagger::FlagFrequency(Mask2DPtr mask, size_t y)
{
	for(size_t x=0;x<mask->Width();++x)
	{
		mask->SetValue(x, y, true);
	}
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:7,代码来源:statisticalflagger.cpp

示例4: FlagTime

void StatisticalFlagger::FlagTime(Mask2DPtr mask, size_t x)
{
	for(size_t y=0;y<mask->Height();++y)
	{
		mask->SetValue(x, y, true);
	}
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:7,代码来源:statisticalflagger.cpp

示例5: ActiveData

void RFIGuiController::PlotPowerTime()
{
	if(IsImageLoaded())
	{
		Plot2D &plot = _plotManager->NewPlot2D("Power over time");
		plot.SetLogarithmicYAxis(true);

		TimeFrequencyData activeData = ActiveData();
		Image2DCPtr image = activeData.GetSingleImage();
		Mask2DPtr mask =
			Mask2D::CreateSetMaskPtr<false>(image->Width(), image->Height());
		Plot2DPointSet &totalPlot = plot.StartLine("Total");
		RFIPlots::MakePowerTimePlot(totalPlot, image, mask, MetaData());

		mask = Mask2D::CreateCopy(activeData.GetSingleMask());
		if(!mask->AllFalse())
		{
			Plot2DPointSet &uncontaminatedPlot = plot.StartLine("Uncontaminated");
			RFIPlots::MakePowerTimePlot(uncontaminatedPlot, image, mask, MetaData());
	
			mask->Invert();
			Plot2DPointSet &rfiPlot = plot.StartLine("RFI");
			RFIPlots::MakePowerTimePlot(rfiPlot, image, mask, MetaData());
		}

		_plotManager->Update();
	}
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:28,代码来源:rfiguicontroller.cpp

示例6: ApplyMarksInFrequency

void StatisticalFlagger::ApplyMarksInFrequency(Mask2DPtr mask, int **flagMarks)
{
	for(size_t x=0;x<mask->Width();++x)
	{
		int startedCount = 0;
		for(size_t y=0;y<mask->Height();++y)
		{
			startedCount += flagMarks[y][x];
			if(startedCount > 0)
				mask->SetValue(x, y, true);
		}
	}
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:13,代码来源:statisticalflagger.cpp

示例7: EnlargeFlags

void StatisticalFlagger::EnlargeFlags(Mask2DPtr mask, size_t timeSize, size_t frequencySize)
{
	Mask2DCPtr old = Mask2D::CreateCopy(mask);
	for(size_t y=0;y<mask->Height();++y)
	{
		size_t top, bottom;
		if(y > frequencySize)
			top = y - frequencySize;
		else
			top = 0;
		if(y + frequencySize < mask->Height() - 1)
			bottom = y + frequencySize;
		else
			bottom = mask->Height() - 1;
		
		for(size_t x=0;x<mask->Width();++x)
		{
			size_t left, right;
			if(x > timeSize)
				left = x - timeSize;
			else
				left = 0;
			if(x + timeSize < mask->Width() - 1)
				right = x + timeSize;
			else
				right = mask->Width() - 1;
			
			if(SquareContainsFlag(old, left, top, right, bottom))
				mask->SetValue(x, y, true);
		}
	}
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:32,代码来源:statisticalflagger.cpp

示例8: 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);
	}
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:26,代码来源:statisticalflagger.cpp

示例9: DensityTimeFlagger

void StatisticalFlagger::DensityTimeFlagger(Mask2DPtr mask, num_t minimumGoodDataRatio)
{
	num_t width = 2.0;
	size_t iterations = 0, step = 1;
	bool reverse = false;
	
	//"sums represents the number of flags in a certain range
	int **sums = new int*[mask->Height()];
	
	// flagMarks are integers that represent the number of times an area is marked as the
	// start or end of a flagged area. For example, if flagMarks[0][0] = 0, it is not the start or
	// end of an area. If it is 1, it is the start. If it is -1, it is the end. A range of
	// [2 0 -1 -1 0] produces a flag mask [T T T T F].
	int **flagMarks = new int*[mask->Height()];
	
	for(size_t y=0;y<mask->Height();++y)
	{
		sums[y] = new int[mask->Width()];
		flagMarks[y] = new int[mask->Width()];
		for(size_t x=0;x<mask->Width();++x)
			flagMarks[y][x] = 0;
	}
	
	MaskToInts(mask, sums);
	
	while(width < mask->Width())
	{
		++iterations;
		SumToLeft(mask, sums, (size_t) width, step, reverse);
		const int maxFlagged = (int) floor((1.0-minimumGoodDataRatio)*(num_t)(width));
		ThresholdTime(mask, flagMarks, sums, maxFlagged, (size_t) width);
	
		num_t newWidth = width * 1.05;
		if((size_t) newWidth == (size_t) width)
			newWidth = width + 1.0;
		step = (size_t) (newWidth - width);
		width = newWidth;
		reverse = !reverse;
	}
	
	ApplyMarksInTime(mask, flagMarks);

	for(size_t y=0;y<mask->Height();++y)
	{
		delete[] sums[y];
		delete[] flagMarks[y];
	}
	delete[] sums;
	delete[] flagMarks;
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:50,代码来源:statisticalflagger.cpp

示例10: 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);
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:48,代码来源:thresholdmitigater.cpp

示例11: 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();
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:38,代码来源:imagetile.cpp

示例12: GetActiveMask

Mask2DCPtr ImageWidget::GetActiveMask() const
{
	if(!HasImage())
		throw std::runtime_error("GetActiveMask() called without image");
	const bool
		originalActive = _showOriginalMask && _originalMask != 0,
		altActive = _showAlternativeMask && _alternativeMask != 0;
	if(originalActive)
	{
		if(altActive)
		{
			Mask2DPtr mask = Mask2D::CreateCopy(_originalMask); 
			mask->Join(_alternativeMask);
			return mask;
		} else
			return _originalMask;
	} else {
		if(altActive)
			return _alternativeMask;
		else
			return Mask2D::CreateSetMaskPtr<false>(_image->Width(), _image->Height());
	}
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:23,代码来源:imagewidget.cpp

示例13: 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);
				}
			}
		}
	}
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:23,代码来源:thresholdmitigater.cpp

示例14: 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);
}
开发者ID:pkgw,项目名称:aoflagger,代码行数:47,代码来源:thresholdmitigater.cpp

示例15: 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);
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:56,代码来源:morphology.cpp


注:本文中的Mask2DPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。