pixelYIQ.h

Go to the documentation of this file.
00001 
00015 #ifndef DLR_COMPUTERVISION_PIXELYIQ_H
00016 #define DLR_COMPUTERVISION_PIXELYIQ_H
00017 
00018 #include <dlrCommon/types.h>
00019 
00020 namespace dlr {
00021 
00022   namespace computerVision {
00023     
00024     template<class TYPE>
00025     struct PixelYIQ
00026     {
00027     public:
00028 
00033       PixelYIQ()
00034         : luma(), inPhase(), quadrature() {}
00035 
00036     
00048       PixelYIQ(const TYPE& luma, const TYPE& inPhase, const TYPE& quadrature)
00049         : luma(luma), inPhase(inPhase), quadrature(quadrature) {}
00050 
00051 
00055       ~PixelYIQ() {}
00056 
00057     
00069       template<class Iter>
00070       inline Iter&
00071       copyFromIterator(Iter& iter);
00072 
00073 
00085       template<class Iter>
00086       inline Iter&
00087       copyToIterator(Iter& iter);
00088 
00089 
00090       /* ====== Public data members ====== */
00091 
00092       TYPE luma;
00093       TYPE inPhase;
00094       TYPE quadrature;
00095 
00096 
00097       /* ====== Static member functions ====== */
00098 
00107       static inline bool
00108       isContiguous();
00109 
00110     };
00111 
00112 
00113     typedef PixelYIQ<UnsignedInt8> PixelYIQ8;
00114     typedef PixelYIQ<UnsignedInt16> PixelYIQ16;
00115     typedef PixelYIQ<Int16> PixelYIQSigned16;
00116     typedef PixelYIQ<Int32> PixelYIQSigned32;
00117     typedef PixelYIQ<Float32> PixelYIQFloat32;
00118     typedef PixelYIQ<Float64> PixelYIQFloat64;
00119 
00120 
00135     template<class TYPE>
00136     inline PixelYIQ<TYPE>
00137     operator-(const PixelYIQ<TYPE>& pixel0, const PixelYIQ<TYPE>& pixel1);
00138 
00139   
00151     template<class TYPE>
00152     inline bool
00153     operator==(const PixelYIQ<TYPE>& pixel0, const PixelYIQ<TYPE>& pixel1);
00154 
00155   } // namespace computerVision
00156 
00157 } // namespace dlr
00158   
00159 /* ============ Definitions of inline & template functions ============ */
00160 
00161 
00162 namespace dlr {
00163 
00164   namespace computerVision {
00165     
00166     // This member function copies the pixel component values, in
00167     // order, from consecutive iterator targets, incrementing the
00168     // iterator after each copy.
00169     template<class TYPE>
00170     template<class Iter>
00171     inline Iter&
00172     PixelYIQ<TYPE>::
00173     copyFromIterator(Iter& iter)
00174     {
00175       luma = *(iter++);
00176       inPhase = *(iter++);
00177       quadrature = *(iter++);
00178       return iter;
00179     }
00180 
00181 
00182     // This member function assigns the pixel component values, in
00183     // order, to consecutive iterator targets, incrementing the
00184     // iterator after each assignment.
00185     template<class TYPE>
00186     template<class Iter>
00187     inline Iter&
00188     PixelYIQ<TYPE>::
00189     copyToIterator(Iter& iter)
00190     {
00191       *(iter++) = luma;
00192       *(iter++) = inPhase;
00193       *(iter++) = quadrature;
00194       return iter;
00195     }
00196 
00197 
00198     // This static member function indicates whether or not a pixel
00199     // instance is memory identical to a contiguous array of Component
00200     // type.
00201     template<class TYPE>
00202     inline bool
00203     PixelYIQ<TYPE>::
00204     isContiguous()
00205     {
00206       TYPE dummy;
00207       TYPE* typePtr = &dummy;
00208       PixelYIQ<TYPE>* pixelPtr = reinterpret_cast<PixelYIQ<TYPE>*>(typePtr);
00209       PixelYIQ<TYPE>* pixelPtr2 = pixelPtr + 1;
00210       return
00211         ((reinterpret_cast<TYPE*>(&(pixelPtr2->luma)) == &(typePtr[3]))
00212          && (reinterpret_cast<TYPE*>(&(pixelPtr2->inPhase)) == &(typePtr[4]))
00213          && (reinterpret_cast<TYPE*>(&(pixelPtr2->quadrature))
00214              == &(typePtr[5])));
00215     }
00216 
00217 
00218     // This operator subtracts the values of the individual color
00219     // components of its arguments.
00220     template<class TYPE>
00221     inline PixelYIQ<TYPE>
00222     operator-(const PixelYIQ<TYPE>& pixel0, const PixelYIQ<TYPE>& pixel1)
00223     {
00224       return PixelYIQ<TYPE>(
00225         pixel0.luma - pixel1.luma,
00226         pixel0.inPhase - pixel1.inPhase,
00227         pixel0.quadrature - pixel1.quadrature);
00228     }
00229 
00230 
00231     // This operator returns true if the contents of the two argments
00232     // are identical, false otherwise.
00233     template<class TYPE>
00234     inline bool
00235     operator==(const PixelYIQ<TYPE>& pixel0, const PixelYIQ<TYPE>& pixel1)
00236     {
00237       return (pixel0.luma == pixel1.luma
00238               && pixel0.inPhase == pixel1.inPhase
00239               && pixel0.quadrature == pixel1.quadrature);
00240     }
00241 
00242   } // namespace computerVision
00243   
00244 } // namespace dlr
00245 
00246 #endif /* #ifndef DLR_COMPUTERVISION_PIXELYIQ_H */

Generated on Wed Nov 25 12:15:05 2009 for dlrComputerVision Utility Library by  doxygen 1.5.8