Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

template<class DstArrayT, class SrcArrayT>
void Impala::Core::Array::Pattern::FuncGeometricOp ( DstArrayT *  dst,
SrcArrayT *  src,
Matrix::Mat *  func,
Geometry::GeoIntType  gi,
Element::Vec3Real64  translate,
typename DstArrayT::ArithType  background 
)

Definition at line 21 of file FuncGeometricOp.h.

References ArrayCH(), ArrayCPB(), ArrayCW(), Impala::Core::Array::Element::E1Cast(), Impala::Core::Geometry::LINEAR, Impala::Core::Matrix::MatMulVec(), PtrRead(), PtrWrite(), Impala::Core::Array::Element::Vec3Real64::X(), Impala::Core::Array::Element::Vec3Real64::Y(), and Impala::Core::Array::Element::Vec3Real64::Z().

Referenced by PatGeometricOp().

00024 {
00025     typedef typename DstArrayT::StorType DstStorT;
00026     typedef typename DstArrayT::ArithType DstArithT;
00027     typedef typename SrcArrayT::StorType SrcStorT;
00028     typedef typename SrcArrayT::ArithType SrcArithT;
00029 
00030     Real64 srcWidth = ArrayCW(src);
00031     Real64 srcHeight = ArrayCH(src);
00032     Real64 maxSrcX = (gi == Geometry::LINEAR) ? srcWidth - 1 : srcWidth - 0.5;
00033     Real64 maxSrcY = (gi == Geometry::LINEAR) ? srcHeight - 1 : srcHeight - 0.5;
00034     int dstWidth = ArrayCW(dst);
00035     int dstHeight = ArrayCH(dst);
00036 
00037     for (int y=0 ; y<dstHeight ; y++)
00038     {
00039         DstStorT* dstPtr = ArrayCPB(dst, 0, y);
00040         for (int x=0 ; x<dstWidth ; x++)
00041         {
00042             Element::Vec3Real64 vDst(x, y, 1);
00043             Element::Vec3Real64 vSrc = Matrix::MatMulVec(func, vDst + translate);
00044             Real64 srcXf = vSrc.X() / vSrc.Z(); // homogeneous coordinates
00045             Real64 srcYf = vSrc.Y() / vSrc.Z();
00046 
00047             DstArithT pixVal;
00048             if ((srcXf<0) || (srcXf>=maxSrcX) || (srcYf<0) || (srcYf>=maxSrcY))
00049                 pixVal = background; // outside image
00050             else
00051             {
00052                 if (gi == Geometry::LINEAR)
00053                 {
00054                     Int32 srcX = Int32(srcXf); // truncate
00055                     Int32 srcY = Int32(srcYf);
00056                     DstArithT alpha = Element::E1Cast(Real64(srcXf - srcX), DstArithT());
00057                     DstArithT beta  = Element::E1Cast(Real64(srcYf - srcY), DstArithT());
00058                     SrcStorT* sPtr;
00059                     sPtr = ArrayCPB(src, srcX, srcY);
00060                     DstArithT v1 = PtrRead(sPtr, SrcArithT());
00061                     sPtr += SrcArrayT::ElemSize();
00062                     DstArithT v2 = PtrRead(sPtr, SrcArithT());
00063                     sPtr = ArrayCPB(src, srcX, srcY+1);
00064                     DstArithT v3 = PtrRead(sPtr, SrcArithT());
00065                     sPtr += SrcArrayT::ElemSize();
00066                     DstArithT v4 = PtrRead(sPtr, SrcArithT());
00067                     pixVal = v1 + alpha*(v2-v1) + beta*(v3-v1)
00068                                 + alpha*beta*(v1-v2-v3+v4);
00069                 }
00070                 else
00071                 { // gi == NEAREST
00072                     SrcStorT* sPtr = ArrayCPB(src, Int32(srcXf + 0.5),
00073                                                 Int32(srcYf + 0.5));
00074                     pixVal = PtrRead(sPtr, SrcArithT());
00075                 }
00076             }
00077             PtrWrite(dstPtr, pixVal);
00078             dstPtr += DstArrayT::ElemSize();
00079         }
00080     }
00081 }

Here is the call graph for this function:


Generated on Fri Mar 19 11:01:10 2010 for ImpalaSrc by  doxygen 1.5.1