EstimateEMOS2<T,N>::EstimateEMOS2( Array< RectDomain<N>, 1>& strata, Array< Array<T,N>, 1>& psfs, Array<T,N>& img, int iterations, T epsilon ) : EstimateIterative<T,N>(psfs(0), img, iterations), epsilon_(epsilon), strata_(strata) { a_.resize(this->img_.extent(0)); strata_.resize(strata.length(0)); psfsF_.resize(psfs.length(0)); TinyVector<int,N> extent(this->img_.extent()); s_.resize(extent); prev_.resize(extent); extent(0) *= 2; s2_.resize(extent); extent(N-1) = extent(N-1)/2+1; estF_.resize(extent); sF_.resize(extent); // resize the psfs and compute the Fourier transform (OTF) for ( int m = 0; m < psfs.length(0); m++ ) { psfsF_(m).resize(extent); Array<T,N> psfResized(s2_.extent()); padCenter(psfs(m), psfResized); psfsF_(m) = forwardFFT(psfResized); } // compute the interpolation constants a_ = 0; int index = strata_(0).lbound(int(0)); for ( int m = 0; m < strata.length(0); m++ ) { int l = strata_(m).lbound(int(0)); int u = strata_(m).ubound(int(0)); int size = u - l + 1; for ( int j = 0; j < size; j++ ) { a_(index) = T(1) - T(j)/T(size); index++; } } // compute the scaling factors scale_ = T(1.0)/strata.length(0); }
void Deconvolution::performSimpleClean(size_t currentChannelIndex, bool& reachedMajorThreshold, size_t majorIterationNr, PolarizationEnum polarization) { deconvolution::SingleImageSet residualImage(_imgWidth*_imgHeight, *_imageAllocator), modelImage(_imgWidth*_imgHeight, *_imageAllocator); ImageBufferAllocator::Ptr psfImage; _imageAllocator->Allocate(_imgWidth*_imgHeight, psfImage); _residualImages->Load(residualImage.Data(), polarization, currentChannelIndex, false); _modelImages->Load(modelImage.Data(), polarization, currentChannelIndex, false); _psfImages->Load(psfImage.data(), _psfPolarization, currentChannelIndex, false); std::vector<double*> psfs(1, psfImage.data()); TypedDeconvolutionAlgorithm<deconvolution::SingleImageSet>& tAlgorithm = static_cast<TypedDeconvolutionAlgorithm<deconvolution::SingleImageSet>&>(*_cleanAlgorithm); tAlgorithm.ExecuteMajorIteration(residualImage, modelImage, psfs, _imgWidth, _imgHeight, reachedMajorThreshold); _modelImages->Store(modelImage.Data(), polarization, currentChannelIndex, false); _residualImages->Store(residualImage.Data(), polarization, currentChannelIndex, false); }
void Deconvolution::performDynamicClean(const class ImagingTable& groupTable, bool& reachedMajorThreshold, size_t majorIterationNr) { _imageAllocator->FreeUnused(); DynamicSet residualSet(&groupTable, *_imageAllocator, _imgWidth, _imgHeight), modelSet(&groupTable, *_imageAllocator, _imgWidth, _imgHeight); size_t imgIndex = 0; for(size_t i=0; i!=groupTable.EntryCount(); ++i) { const ImagingTableEntry& e = groupTable[i]; if(e.imageCount >= 1) { _residualImages->Load(residualSet[imgIndex], e.polarization, e.outputChannelIndex, false); _modelImages->Load(modelSet[imgIndex], e.polarization, e.outputChannelIndex, false); ++imgIndex; } if(e.imageCount == 2) { _residualImages->Load(residualSet[imgIndex], e.polarization, e.outputChannelIndex, true); _modelImages->Load(modelSet[imgIndex], e.polarization, e.outputChannelIndex, true); ++imgIndex; } } imgIndex = 0; std::vector<ao::uvector<double>> psfVecs(groupTable.SquaredGroupCount()); for(size_t i=0; i!=groupTable.SquaredGroupCount(); ++i) { ImagingTable subTable = groupTable.GetSquaredGroup(i); const ImagingTableEntry& e = subTable.Front(); if(e.imageCount >= 1) { psfVecs[imgIndex].resize(_imgWidth * _imgHeight); _psfImages->Load(psfVecs[imgIndex].data(), _psfPolarization, e.outputChannelIndex, false); ++imgIndex; } if(e.imageCount == 2) { psfVecs[imgIndex].resize(_imgWidth * _imgHeight); _psfImages->Load(psfVecs[imgIndex].data(), _psfPolarization, e.outputChannelIndex, true); ++imgIndex; } } ao::uvector<const double*> psfs(groupTable.SquaredGroupCount()); for(size_t i=0; i!=psfVecs.size(); ++i) psfs[i] = psfVecs[i].data(); UntypedDeconvolutionAlgorithm& algorithm = static_cast<UntypedDeconvolutionAlgorithm&>(*_cleanAlgorithm); algorithm.ExecuteMajorIteration(residualSet, modelSet, psfs, _imgWidth, _imgHeight, reachedMajorThreshold); imgIndex = 0; for(size_t i=0; i!=groupTable.EntryCount(); ++i) { const ImagingTableEntry& e = groupTable[i]; if(e.imageCount >= 1) { _residualImages->Store(residualSet[imgIndex], e.polarization, e.outputChannelIndex, false); _modelImages->Store(modelSet[imgIndex], e.polarization, e.outputChannelIndex, false); ++imgIndex; } if(e.imageCount == 2) { _residualImages->Store(residualSet[imgIndex], e.polarization, e.outputChannelIndex, true); _modelImages->Store(modelSet[imgIndex], e.polarization, e.outputChannelIndex, true); ++imgIndex; } } }