Isis 3.0 Application Source Code Reference |
Home |
00001 #if !defined(SplineFill_h) 00002 #define SplineFill_h 00003 /** 00004 * @file 00005 * $Revision: 3878 $ 00006 * $Date: 2012-01-18 10:23:13 -0700 (Wed, 18 Jan 2012) $ 00007 * $Id: SplineFill.h 3878 2012-01-18 17:23:13Z slambright@GS.DOI.NET $ 00008 * 00009 * Unless noted otherwise, the portions of Isis written by the USGS are 00010 * public domain. See individual third-party library and package descriptions 00011 * for intellectual property information, user agreements, and related 00012 * information. 00013 * 00014 * Although Isis has been used by the USGS, no warranty, expressed or 00015 * implied, is made by the USGS as to the accuracy and functioning of such 00016 * software and related material nor shall the fact of distribution 00017 * constitute any such warranty, and no responsibility is assumed by the 00018 * USGS in connection therewith. 00019 * 00020 * For additional information, launch 00021 * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html 00022 * in a browser or see the Privacy & Disclaimers page on the Isis website, 00023 * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on 00024 * http://www.usgs.gov/privacy.html. 00025 */ 00026 00027 #include <string> 00028 #include <vector> 00029 00030 #include "iString.h" 00031 #include "Module.h" 00032 #include "NumericalApproximation.h" 00033 #include "SpecialPixel.h" 00034 #include "iException.h" 00035 00036 namespace Isis { 00037 00038 /** 00039 * @brief Compute a low pass filter from a Module class content 00040 * 00041 * @ingroup Utility 00042 * 00043 * @author 2007-10-09 Kris Becker 00044 * 00045 * @internal 00046 * @history 2008-11-05 Jeannie Walldren Replaced references to 00047 * DataInterp class with NumericalApproximation. 00048 */ 00049 class SplineFill : public Module { 00050 00051 public: 00052 // Constructors and Destructor 00053 SplineFill() : Module("SplineFill"), _filled(0) { } 00054 00055 SplineFill(const Module &c) : 00056 Module("SplineFill", c), _filled(0) { 00057 fill(c.ref()); 00058 _history.add(formHistory()); 00059 } 00060 00061 SplineFill(const HiVector &v) : 00062 Module("SplineFill"), _filled(0) { 00063 fill(v); 00064 _history.add(formHistory()); 00065 } 00066 SplineFill(const HiVector &v, const HiHistory &h) : 00067 Module("SplineFill", h), _filled(0) { 00068 fill(v); 00069 _history.add(formHistory()); 00070 } 00071 00072 /** Destructor */ 00073 virtual ~SplineFill() { } 00074 00075 void Process(const HiVector &v) { 00076 fill(v); 00077 _history.clear(); 00078 _history.add(formHistory()); 00079 } 00080 00081 inline int Filled() const { return (_filled); } 00082 00083 private: 00084 int _filled; //!< Number values replaced 00085 00086 std::string formHistory() { 00087 iString cfilled(_filled); 00088 return (std::string("SplineFill(Cubic,Filled[" + cfilled + "])")); 00089 } 00090 00091 void fill(const HiVector &v) { 00092 NumericalApproximation spline(NumericalApproximation::CubicNatural); 00093 for (int i = 0 ; i < v.dim() ; i++) { 00094 if (!IsSpecial(v[i])) { 00095 spline.AddData(i, v[i]); 00096 } 00097 } 00098 00099 // Compute the spline and fill missing data 00100 HiVector vout(v.dim()); 00101 _filled = 0; 00102 for (int j = 0 ; j < v.dim() ; j++) { 00103 if (IsSpecial(v[j])) { 00104 vout[j] = spline.Evaluate(j,NumericalApproximation::NearestEndpoint); 00105 _filled++; 00106 } 00107 else { 00108 vout[j] = v[j]; 00109 } 00110 } 00111 00112 _data = vout; 00113 return; 00114 } 00115 }; 00116 00117 } // namespace Isis 00118 #endif 00119