qAutoStereo_20190430/qas/src/main/cpp/btk/b_ImageEm/ComplexImage.c
/** copies a section of given image */
copies a section of given image
copies a section of given image
void bim_ComplexImage_copySection( struct bbs_Context* cpA,
								   struct bim_ComplexImage* ptrA, 
								   const struct bim_ComplexImage* srcPtrA, 
								   const struct bts_Int16Rect* sectionPtrA )
{
	struct bbs_Complex* srcPixelPtrL;
	struct bbs_Complex* dstPixelPtrL;
	int32 yIndexL;
	int32 xIndexL;
	struct bts_Int16Rect srcImageSubSectionL;
	struct bts_Int16Rect sectionL;
	sectionL.x1E = bbs_min( sectionPtrA->x1E, sectionPtrA->x2E );
	sectionL.x2E = bbs_max( sectionPtrA->x1E, sectionPtrA->x2E );
	sectionL.y1E = bbs_min( sectionPtrA->y1E, sectionPtrA->y2E );
	sectionL.y2E = bbs_max( sectionPtrA->y1E, sectionPtrA->y2E );
	srcImageSubSectionL.x1E = bbs_max( 0, sectionL.x1E );
	srcImageSubSectionL.y1E = bbs_max( 0, sectionL.y1E );
	srcImageSubSectionL.x2E = bbs_min( ( int32 ) srcPtrA->widthE, sectionL.x2E );
	srcImageSubSectionL.y2E = bbs_min( ( int32 ) srcPtrA->heightE, sectionL.y2E );
	if( srcImageSubSectionL.x2E < srcImageSubSectionL.x1E )
	{
		srcImageSubSectionL.x1E = 0;
		srcImageSubSectionL.x2E = srcPtrA->widthE;
	}
	if( srcImageSubSectionL.y2E < srcImageSubSectionL.y1E )
	{
		srcImageSubSectionL.y1E = 0;
		srcImageSubSectionL.y2E = srcPtrA->heightE;
	}
	bim_ComplexImage_size( cpA, ptrA, sectionL.x2E - sectionL.x1E, sectionL.y2E - sectionL.y1E );
	dstPixelPtrL = ptrA->arrE.arrPtrE;
	for( yIndexL = sectionL.y1E; yIndexL < srcImageSubSectionL.y1E && yIndexL < sectionL.y2E; yIndexL++ )
	{
		srcPixelPtrL = srcPtrA->arrE.arrPtrE;
		for( xIndexL = sectionL.x1E; xIndexL < srcImageSubSectionL.x1E && xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL;
		}
		for( ; xIndexL < srcImageSubSectionL.x2E && xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL++;
		}
		srcPixelPtrL--;
		for( ; xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL;
		}
	}
	for( ; yIndexL < srcImageSubSectionL.y2E && yIndexL < sectionL.y2E; yIndexL++ )
	{
		srcPixelPtrL = srcPtrA->arrE.arrPtrE + yIndexL * srcPtrA->widthE + srcImageSubSectionL.x1E;
		for( xIndexL = sectionL.x1E; xIndexL < srcImageSubSectionL.x1E && xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL;
		}
		for( ; xIndexL < srcImageSubSectionL.x2E && xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL++;
		}
		srcPixelPtrL--;
		for( ; xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL;
		}
	}
	for( ; yIndexL < sectionL.y2E; yIndexL++ )
	{
		srcPixelPtrL = srcPtrA->arrE.arrPtrE + ( srcImageSubSectionL.y2E - 1 ) * srcPtrA->widthE + srcImageSubSectionL.x1E;
		for( xIndexL = sectionL.x1E; xIndexL < srcImageSubSectionL.x1E && xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL;
		}
		for( ; xIndexL < srcImageSubSectionL.x2E && xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL++;
		}
		srcPixelPtrL--;
		for( ; xIndexL < sectionL.x2E; xIndexL++ )
		{
			*dstPixelPtrL++ = *srcPixelPtrL;
		}
	}
}
void bim_ComplexImage_copySection ( struct bbs_Context * cpA , struct bim_ComplexImage * ptrA , const struct bim_ComplexImage * srcPtrA , const struct bts_Int16Rect * sectionPtrA ) { struct bbs_Complex * srcPixelPtrL ; struct bbs_Complex * dstPixelPtrL ; int32 yIndexL ; int32 xIndexL ; struct bts_Int16Rect srcImageSubSectionL ; struct bts_Int16Rect sectionL ; sectionL . x1E = bbs_min ( sectionPtrA -> x1E , sectionPtrA -> x2E ) ; sectionL . x2E = bbs_max ( sectionPtrA -> x1E , sectionPtrA -> x2E ) ; sectionL . y1E = bbs_min ( sectionPtrA -> y1E , sectionPtrA -> y2E ) ; sectionL . y2E = bbs_max ( sectionPtrA -> y1E , sectionPtrA -> y2E ) ; srcImageSubSectionL . x1E = bbs_max ( 0 , sectionL . x1E ) ; srcImageSubSectionL . y1E = bbs_max ( 0 , sectionL . y1E ) ; srcImageSubSectionL . x2E = bbs_min ( ( int32 ) srcPtrA -> widthE , sectionL . x2E ) ; srcImageSubSectionL . y2E = bbs_min ( ( int32 ) srcPtrA -> heightE , sectionL . y2E ) ; if ( srcImageSubSectionL . x2E < srcImageSubSectionL . x1E ) { srcImageSubSectionL . x1E = 0 ; srcImageSubSectionL . x2E = srcPtrA -> widthE ; } if ( srcImageSubSectionL . y2E < srcImageSubSectionL . y1E ) { srcImageSubSectionL . y1E = 0 ; srcImageSubSectionL . y2E = srcPtrA -> heightE ; } bim_ComplexImage_size ( cpA , ptrA , sectionL . x2E - sectionL . x1E , sectionL . y2E - sectionL . y1E ) ; dstPixelPtrL = ptrA -> arrE . arrPtrE ; for ( yIndexL = sectionL . y1E ; yIndexL < srcImageSubSectionL . y1E && yIndexL < sectionL . y2E ; yIndexL ++ ) { srcPixelPtrL = srcPtrA -> arrE . arrPtrE ; for ( xIndexL = sectionL . x1E ; xIndexL < srcImageSubSectionL . x1E && xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ; } for ( ; xIndexL < srcImageSubSectionL . x2E && xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ++ ; } srcPixelPtrL -- ; for ( ; xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ; } } for ( ; yIndexL < srcImageSubSectionL . y2E && yIndexL < sectionL . y2E ; yIndexL ++ ) { srcPixelPtrL = srcPtrA -> arrE . arrPtrE + yIndexL * srcPtrA -> widthE + srcImageSubSectionL . x1E ; for ( xIndexL = sectionL . x1E ; xIndexL < srcImageSubSectionL . x1E && xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ; } for ( ; xIndexL < srcImageSubSectionL . x2E && xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ++ ; } srcPixelPtrL -- ; for ( ; xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ; } } for ( ; yIndexL < sectionL . y2E ; yIndexL ++ ) { srcPixelPtrL = srcPtrA -> arrE . arrPtrE + ( srcImageSubSectionL . y2E - 1 ) * srcPtrA -> widthE + srcImageSubSectionL . x1E ; for ( xIndexL = sectionL . x1E ; xIndexL < srcImageSubSectionL . x1E && xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ; } for ( ; xIndexL < srcImageSubSectionL . x2E && xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ++ ; } srcPixelPtrL -- ; for ( ; xIndexL < sectionL . x2E ; xIndexL ++ ) { * dstPixelPtrL ++ = * srcPixelPtrL ; } } }
copies a section of given image
copies a section of given image
/* make sure that the rectangle passed is correct, in case the x2 < x1 or y2 < y1, swap them */ /* find the intersection betweem the rectangle and the image, the image always starts at 0,0 */ /* If the image and the rectangle do not intersect in X direction, set the intersecting rectangle to the image coordinates */ /* do the same as above in the Y direction */ /* set size, and allocate required memory for the destination image if required */ /* get the pointer to the destination image */ /* 1. parse all pixels in "loop y1" */ /* move to the first pixel that needs to be copied. */ /* 1.a. parse all pixels in "loop x1" */ /* 1.b. parse all pixels in "loop x2" */ /* 1.c. parse all pixels in "loop x3" */ /* 2. parse all pixels in "loop y2" */ /* move to the first pixel that needs to be copied. */ /* 2.a. parse all pixels in "loop x1" */ /* 2.b. parse all pixels in "loop x2" */ /* 2.c. parse all pixels in "loop x3" */ /* 3. parse all pixels in "loop y3" */ /* 3.a. parse all pixels in "loop x1" */ /* 3.b. parse all pixels in "loop x3" */ /* 3.c. parse all pixels in "loop x3" */