#include namespace icl{ template void ImgBorder::fixed(Img *im, T* val){ // {{{ open /** clear strategy: (top) tttttttttttttttttttttt tttttttttttttttttttttt lll.................rr (left)lll.....(image-.....rr(right) lll......ROI).......rr lll.................rr bbbbbbbbbbbbbbbbbbbbbb (bottom) */ FUNCTION_LOG(""); ICLASSERT_RETURN( im ); Rect roi = im->getROI(); Size s = im->getSize(); for(int c=0;cgetChannels();c++){ // top clearChannelROI(im,c,val[c], Point::null, Size(s.width,roi.top())); // bottom clearChannelROI(im,c,val[c], Point(0,roi.bottom()), Size(s.width,s.height-roi.bottom())); // left clearChannelROI(im,c,val[c], Point(0,roi.top()), Size(roi.left(),roi.height)); // right clearChannelROI(im,c,val[c], roi.ur(), Size(s.width-roi.right(),roi.height) ); } } // }}} // export these functions template void ImgBorder::fixed(Img *im,icl8u *val); template void ImgBorder::fixed(Img *im,icl32f *val); template inline void _copy_border(Img *poImage){ // {{{ open Rect im = Rect(Point::null,poImage->getSize()); Rect roi = poImage->getROI(); Rect aR[4] = { Rect(0, 0, roi.x+1 ,roi.y+1), // upper left Rect(roi.right()-1,0, im.width-roi.right()+1,roi.y+1), // upper right Rect(roi.right()-1,roi.bottom()-1,im.width-roi.right()+1,im.height-roi.bottom()+1), // lower right Rect(0, roi.bottom()-1,roi.x+1, im.height-roi.bottom()+1) // lower left }; T aPix[4]; for(int c=0;cgetChannels();c++) { aPix[0] = (*poImage)(roi.x, roi.y, c);// = 255; // upper left aPix[1] = (*poImage)(roi.right()-1, roi.y, c);// = 255; // upper right aPix[2] = (*poImage)(roi.right()-1, roi.bottom()-1, c);// = 255; // lower right aPix[3] = (*poImage)(roi.x, roi.bottom()-1, c);// = 255; // lower left // clear the corners for(int i=0;i<4;i++) { clearChannelROI(poImage,c,aPix[i],aR[i].ul(),aR[i].size()); } // copy the borders // Point srcOffs; Size srcDstSize; srcOffs = Point(roi.x,roi.y+1); srcDstSize = Size(1,roi.height-2); if(roi.x>0){ for(Point p(0,roi.y+1);p.x!=roi.x;p.x++){ deepCopyChannelROI(poImage,c, srcOffs, srcDstSize, poImage,c,p,srcDstSize); } } // srcOffs.x=roi.right()-1; if(roi.right() < im.right()){ for(Point p(srcOffs.x+1,srcOffs.y);p.x srcOffs = Point(roi.x+1,roi.y); srcDstSize = Size(roi.width-2,1); if(roi.y>0){ for(Point p(srcOffs.x,roi.y+1);p.y>=0;p.y--){ deepCopyChannelROI(poImage,c, srcOffs, srcDstSize, poImage,c,p,srcDstSize); } } // if(roi.bottom()hasFullROI()) return; switch (poImage->getDepth()){ case depth8u: #ifdef WITH_IPP_OPTIMIZATION for(int c=0;cgetChannels();c++){ ippiCopyReplicateBorder_8u_C1IR(poImage->asImg()->getROIData(c),poImage->getLineStep(), poImage->getROISize(),poImage->getSize(), poImage->getROIOffset().x,poImage->getROIOffset().y); } #else _copy_border(poImage->asImg()); #endif break; case depth32f: #ifdef WITH_IPP_OPTIMIZATION for(int c=0;cgetChannels();c++){ /// icl32f-case using Ipp32s method ippiCopyReplicateBorder_32s_C1IR((Ipp32s*)(poImage->asImg()->getROIData(c)),poImage->getLineStep(), poImage->getROISize(),poImage->getSize(), poImage->getROIOffset().x,poImage->getROIOffset().y); } #else _copy_border(poImage->asImg()); #endif break; default: ICL_INVALID_FORMAT; break; } } // }}} void ImgBorder::fromOther(ImgBase *dst, ImgBase* src){ // {{{ open FUNCTION_LOG(""); ICLASSERT_RETURN( dst && src ); ICLASSERT_RETURN( dst->isEqual(src->getSize(),src->getChannels()) ); Rect roi = dst->getROI(); Size s = dst->getSize(); Point offs[4] = { Point::null, // top Point(0,roi.bottom()), // bottom Point(0,roi.top()), // left roi.ur() // right }; Size size[4] = { Size(s.width,roi.top()), // top Size(s.width,s.height-roi.bottom()), // bottom Size(roi.left(),roi.height), // left Size(s.width-roi.right(),roi.height) // right }; switch (src->getDepth()){ case depth8u: switch (dst->getDepth()){ case depth8u: for(int c=0;cgetChannels();c++){ for(int i=0;i<4;i++){ deepCopyChannelROI(src->asImg(),c,offs[i],size[i],dst->asImg(),c,offs[i],size[i]); } } break; case depth32f: for(int c=0;cgetChannels();c++){ for(int i=0;i<4;i++){ deepCopyChannelROI(src->asImg(),c,offs[i],size[i],dst->asImg(),c,offs[i],size[i]); } } break; default: ICL_INVALID_FORMAT; break; } break; case depth32f: switch (dst->getDepth()){ case depth8u: for(int c=0;cgetChannels();c++){ for(int i=0;i<4;i++){ deepCopyChannelROI(src->asImg(),c,offs[i],size[i],dst->asImg(),c,offs[i],size[i]); } } break; case depth32f: for(int c=0;cgetChannels();c++){ for(int i=0;i<4;i++){ deepCopyChannelROI(src->asImg(),c,offs[i],size[i],dst->asImg(),c,offs[i],size[i]); } } break; default: ICL_INVALID_FORMAT; break; } break; default: ICL_INVALID_FORMAT; break; } } // }}} }