本文整理汇总了C++中Image2DCPtr类的典型用法代码示例。如果您正苦于以下问题:C++ Image2DCPtr类的具体用法?C++ Image2DCPtr怎么用?C++ Image2DCPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image2DCPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ActiveData
void RFIGuiController::PlotPowerRMS()
{
if(IsImageLoaded())
{
Plot2D &plot = _plotManager->NewPlot2D("Spectrum RMS");
plot.SetLogarithmicYAxis(true);
TimeFrequencyData activeData = ActiveData();
Image2DCPtr image = activeData.GetSingleImage();
Mask2DPtr mask =
Mask2D::CreateSetMaskPtr<false>(image->Width(), image->Height());
Plot2DPointSet &beforeSet = plot.StartLine("Before");
RFIPlots::MakeRMSSpectrumPlot(beforeSet, image, mask);
mask = Mask2D::CreateCopy(activeData.GetSingleMask());
if(!mask->AllFalse())
{
Plot2DPointSet &afterSet = plot.StartLine("After");
RFIPlots::MakeRMSSpectrumPlot(afterSet, image, mask);
//mask->Invert();
//Plot2DPointSet &rfiSet = plot.StartLine("RFI");
//RFIPlots::MakeRMSSpectrumPlot(rfiSet, _timeFrequencyWidget.Image(), mask);
}
_plotManager->Update();
}
}
示例2: IncreaseFrequency
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);
}
}
}
示例3: PlotPowerSNR
void RFIGuiController::PlotPowerSNR()
{
Image2DCPtr
image = ActiveData().GetSingleImage(),
model = RevisedData().GetSingleImage();
if(IsImageLoaded())
{
Plot2D &plot = _plotManager->NewPlot2D("SNR spectrum");
plot.SetLogarithmicYAxis(true);
Mask2DPtr mask =
Mask2D::CreateSetMaskPtr<false>(image->Width(), image->Height());
Plot2DPointSet &totalPlot = plot.StartLine("Total");
RFIPlots::MakeSNRSpectrumPlot(totalPlot, image, model, mask);
mask = Mask2D::CreateCopy(ActiveData().GetSingleMask());
if(!mask->AllFalse())
{
Plot2DPointSet &uncontaminatedPlot = plot.StartLine("Uncontaminated");
RFIPlots::MakeSNRSpectrumPlot(uncontaminatedPlot, image, model, mask);
mask->Invert();
Plot2DPointSet &rfiPlot = plot.StartLine("RFI");
RFIPlots::MakeSNRSpectrumPlot(rfiPlot, image, model, mask);
}
_plotManager->Update();
}
}
示例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: AutomaticSelection
/**
* Automatic selection selects all timesteps which RMS is higher than some value relative to the stddev of
* all timesteps.
*/
void TimeSelectionAction::AutomaticSelection(ArtifactSet &artifacts)
{
Image2DCPtr image = artifacts.ContaminatedData().GetSingleImage();
SampleRowPtr timesteps = SampleRow::CreateEmpty(image->Width());
Mask2DPtr mask = Mask2D::CreateCopy(artifacts.ContaminatedData().GetSingleMask());
for(size_t x=0;x<image->Width();++x)
{
SampleRowPtr row = SampleRow::CreateFromColumnWithMissings(image, mask, x);
timesteps->SetValue(x, row->RMSWithMissings());
}
bool change;
MedianWindow<num_t>::SubtractMedian(timesteps, 512);
do {
num_t median = 0.0;
num_t stddev = timesteps->StdDevWithMissings(0.0);
change = false;
for(size_t x=0;x<timesteps->Size();++x)
{
if(!timesteps->ValueIsMissing(x) && (timesteps->Value(x) - median > stddev * _threshold || median - timesteps->Value(x) > stddev * _threshold))
{
mask->SetAllVertically<true>(x);
timesteps->SetValueMissing(x);
change = true;
}
}
} while(change);
artifacts.ContaminatedData().SetGlobalMask(mask);
}
示例6: sumAutoCorrelations
num_t SpatialCompositionAction::sumAutoCorrelations(Image2DCPtr image) const
{
num_t sum = 0;
for(size_t y=0;y<image->Height();++y)
{
sum += image->Value(y, y);
}
return sum;
}
示例7: sumCrossCorrelations
num_t SpatialCompositionAction::sumCrossCorrelations(Image2DCPtr image) const
{
num_t sum = 0;
for(size_t y=0;y<image->Height();++y)
{
for(size_t x=0;x<y;++x)
sum += image->Value(x, y);
}
return sum;
}
示例8: elementWiseDivide
void HighPassFilter::elementWiseDivide(const Image2DPtr &leftHand, const Image2DCPtr &rightHand)
{
for(unsigned y=0;y<leftHand->Height();++y) {
for(unsigned x=0;x<leftHand->Width();++x) {
if(rightHand->Value(x, y) == 0.0)
leftHand->SetValue(x, y, 0.0);
else
leftHand->SetValue(x, y, leftHand->Value(x, y) / rightHand->Value(x, y));
}
}
}
示例9: ApplyLowPass
Image2DPtr HighPassFilter::ApplyLowPass(const Image2DCPtr &image, const Mask2DCPtr &mask)
{
initializeKernel();
Image2DPtr
outputImage = Image2D::CreateUnsetImagePtr(image->Width(), image->Height()),
weights = Image2D::CreateUnsetImagePtr(image->Width(), image->Height());
setFlaggedValuesToZeroAndMakeWeightsSSE(image, outputImage, mask, weights);
applyLowPassSSE(outputImage);
applyLowPassSSE(weights);
elementWiseDivideSSE(outputImage, weights);
weights.reset();
return outputImage;
}
示例10: lock
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);
}
}
示例11: 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;
}
示例12: 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);
}
示例13: 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);
}
示例14: DecreaseFrequency
void ChangeResolutionAction::DecreaseFrequency(TimeFrequencyData &timeFrequencyData)
{
size_t imageCount = timeFrequencyData.ImageCount();
for(size_t i=0;i<imageCount;++i)
{
Image2DCPtr image = timeFrequencyData.GetImage(i);
Image2DPtr newImage = image->ShrinkVertically(_frequencyDecreaseFactor);
timeFrequencyData.SetImage(i, newImage);
}
size_t maskCount = timeFrequencyData.MaskCount();
for(size_t i=0;i<maskCount;++i)
{
Mask2DCPtr mask = timeFrequencyData.GetMask(i);
Mask2DPtr newMask = mask->ShrinkVertically(_frequencyDecreaseFactor);
timeFrequencyData.SetMask(i, newMask);
}
}
示例15: subtracted
void ImagePlaneWindow::onMemorySubtractClicked()
{
if(_memory != 0)
{
Image2DPtr subtracted(Image2D::MakePtr(*_memory));
Image2DCPtr old = _heatMapPlot.Image();
for(size_t y=0;y<subtracted->Height();++y)
{
for(size_t x=0;x<subtracted->Width();++x)
{
subtracted->SetValue(x, y, subtracted->Value(x, y) - old->Value(x, y));
}
}
_heatMapPlot.SetImage(std::move(subtracted));
_imageWidget.Update();
printStats();
}
}