LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - ImagePadder.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 49 0.0 %
Date: 2024-10-10 11:40:37 Functions: 0 6 0.0 %

          Line data    Source code
       1             : //# tSubImage.cc: Test program for class SubImage
       2             : //# Copyright (C) 1998,1999,2000,2001,2003
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This program is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU General Public License as published by the Free
       7             : //# Software Foundation; either version 2 of the License, or (at your option)
       8             : //# any later version.
       9             : //#
      10             : //# This program is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
      13             : //# more details.
      14             : //#
      15             : //# You should have received a copy of the GNU General Public License along
      16             : //# with this program; if not, write to the Free Software Foundation, Inc.,
      17             : //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id: $
      27             : 
      28             : #include <imageanalysis/ImageAnalysis/ImagePadder.h>
      29             : 
      30             : #include <imageanalysis/ImageAnalysis/SubImageFactory.h>
      31             : #include <casacore/images/Images/TempImage.h>
      32             : #include <casacore/images/Images/ImageUtilities.h>
      33             : 
      34             : using namespace casacore;
      35             : namespace casa {
      36             : 
      37             : const String ImagePadder::_class = "ImagePadder";
      38             : 
      39           0 : ImagePadder::ImagePadder(
      40             :         const SPCIIF image,
      41             :     const Record *const regionRec,
      42             :     const String& box,
      43             :     const String& chanInp, const String& stokes,
      44             :     const String& maskInp, const String& outname,
      45             :     const Bool overwrite
      46           0 : ) : ImageTask<Float>(
      47             :         image, "", regionRec, box, chanInp, stokes,
      48             :         maskInp, outname, overwrite
      49           0 :     ), _nPixels(0), _value(0), _good(False) {
      50           0 :     _construct();
      51           0 : }
      52             : 
      53           0 : ImagePadder::~ImagePadder() {}
      54             : 
      55           0 : void ImagePadder::setPaddingPixels(
      56             :     const uInt nPixels, const Float value,
      57             :     const Bool good
      58             : ) {
      59           0 :     _nPixels = nPixels;
      60           0 :     _value = value;
      61           0 :     _good = good;
      62           0 : }
      63             : 
      64           0 : SPIIF ImagePadder::pad(const Bool wantReturn) const {
      65           0 :     *_getLog() << LogOrigin(_class, __FUNCTION__, WHERE);
      66             :     std::shared_ptr<const SubImage<Float> > subImage = SubImageFactory<Float>::createSubImageRO(
      67           0 :         *this->_getImage(), *_getRegion(), _getMask(),
      68           0 :         _getLog().get(), AxesSpecifier(), _getStretch()
      69           0 :     );
      70           0 :     Vector<Int> dirAxes = subImage->coordinates().directionAxesNumbers();
      71           0 :     IPosition outShape = subImage->shape();
      72           0 :     outShape[dirAxes[0]] += 2*_nPixels;
      73           0 :     outShape[dirAxes[1]] += 2*_nPixels;
      74           0 :     CoordinateSystem newCoords = subImage->coordinates();
      75           0 :     Vector<Double> refpix = newCoords.referencePixel();
      76           0 :     refpix[dirAxes[0]] += _nPixels;
      77           0 :     refpix[dirAxes[1]] += _nPixels;
      78           0 :     newCoords.setReferencePixel(refpix);
      79           0 :     ArrayLattice<Bool> mask(outShape);
      80           0 :     mask.set(_good);
      81           0 :     IPosition blc(subImage->ndim(), 0);
      82           0 :     blc[dirAxes[0]] = _nPixels;
      83           0 :     blc[dirAxes[1]] = _nPixels;
      84           0 :     if (subImage->isMasked() || ! _good) {
      85           0 :         IPosition end = subImage->shape();
      86           0 :         Slicer slice(blc, end, Slicer::endIsLength);
      87           0 :         SubLattice<Bool> subLatt(mask, slice, True);
      88           0 :         ImageTask<Float>::_copyMask(subLatt, *subImage);
      89           0 :     }
      90           0 :     Array<Float> valArray(outShape, _value);
      91           0 :     ArrayLattice<Float> values(valArray);
      92           0 :     values.putSlice(subImage->get(), blc);
      93           0 :     const Array<Float>& vals = values.get();
      94           0 :     this->_reportOldNewImageShapes(outShape);
      95             :     SPIIF outImage = _prepareOutputImage(
      96           0 :         *subImage, &vals, &mask, &outShape, &newCoords
      97           0 :     );
      98           0 :     if (! wantReturn) {
      99           0 :         outImage.reset();
     100             :     }
     101           0 :     return outImage;
     102           0 : }
     103             : 
     104           0 : String ImagePadder::getClass() const {
     105           0 :     return _class;
     106             : }
     107             : 
     108             : }
     109             : 
     110             : 

Generated by: LCOV version 1.16