#ifndef IPBINCOMPAREB_HH #define IPBINCOMPAREB_HH //////////////////////////////////////////////////////////////////////////// //! author="Robert Crida" //! lib=IPBinary //! date="27/3/1998" //! userlevel=Develop //! docentry="Image.Image Processing.Operators" //! file="amma/Image/IPStream/IPBinary/IPBinCompareB.hh" //! rcsid="$Id: IPBinCompareB.hh,v 1.7 1999/08/11 13:43:05 ees1cg Exp $" #include "amma/Image/IPBinaryB.hh" // -------------------------------------------------------------------------- // ********** IPBinCompareBC ********************************************** // -------------------------------------------------------------------------- //: Implementation class for image comparison operator. // // Implementation class for image comparison. You should not use this class // directly, but rather the handle class IPBinCompareC. template class IPBinCompareBC: public IPBinaryBC { ImageC _ref; //: Reference image RealT _scale; //: Scale factor for reference RealT _offset; //: Offset for reference ByteGreyValueT _low; //: Below threshold image value ByteGreyValueT _high; //: Above threshold image value public: IPBinCompareBC (const ImageC &ref, RealT scale, RealT offset, ByteGreyValueT low, ByteGreyValueT high); //: Constructor //!param: ref - the reference image //!param: scale - scale factor for reference //!param: offset - offset for reference //!param: low - image value when below threshold //!param: high - image value when above threshold // When applied, the image oth is compared using the expression //
output[pxl] = oth[pxl] >= ref[pxl]*scale+offset? high: low;
IPBinCompareBC (const IPBinCompareBC &oth); //: Copy constructor virtual BodyRefCounterVC & Copy () const; //: Makes a deep copy and is virtual protected: virtual ImageC Apply (const ImageC &oth) const; //: Performs comparison of oth to reference // See the contructor for details of the comparison expression. }; //////////////////////////////////////////// #include "amma/Image3Iter.hh" template IPBinCompareBC::IPBinCompareBC (const ImageC &ref, RealT scale, RealT offset, ByteGreyValueT low, ByteGreyValueT high) :_ref(ref), _scale(scale), _offset(offset), _low(low), _high(high) {} template IPBinCompareBC::IPBinCompareBC (const IPBinCompareBC &oth) :IPBinaryBC(oth), _ref(oth._ref.Copy()), _scale(oth._scale), _offset(oth._offset), _low(oth._low), _high(oth._high) {} template BodyRefCounterVC & IPBinCompareBC::Copy () const { return *(new IPBinCompareBC (*this)); } template ImageC IPBinCompareBC::Apply (const ImageC &oth) const { ImageC temp (oth.Rectangle()); for (Image3IterC e (oth,_ref,temp); e.IsElm(); e.Next()) e.Data3() = e.Data1() >= (e.Data2()*_scale+_offset)? _high: _low; return temp; } #endif