/*! ************************************************************************************* * \function process_glassy * * \brief * This function processes the glassy effect opertation. * * ************************************************************************************* */ void process_glassy(st_API_parameters *p) { int api_return_val ; TIME_START /* Start Timer */ p->spare_roiSize.width = 1 ; p->spare_roiSize.height = 1 ; int k =0 ; int xhalf = p->x_len / 2 ; int yhalf = p->y_len / 2 ; int xplus = p->x_len % 2 ; int yplus = p->y_len % 2 ; int yAllow = 0 ; int yOffset = 0 ; int xAllow = 0 ; int xOffset = 0 ; Fw32f threshold ; Fw32f * xPixel ; Fw32f * yPixel ; xPixel = (float*)malloc(4); yPixel = (float*)malloc(4); for (int y=0 ; y < p->bor_height ; y++) { p->srcStep = 1 ; yPixel[0] = (Fw32f)(yAllow + yOffset * 2); /*--------------------------------------------------------------------------------*/ /* Calling API "fwiThreshold_GT_32f_C1IR" : */ /* */ /* This functions steps through an ROI in a source buffer and compares */ /* source data to a specified threshold value. When the source data is */ /* greater than the threshold value, the output data is set to the threshold */ /* value. */ /* */ /*--------------------------------------------------------------------------------*/ threshold = (Fw32f)(p->bor_height - 1) ; api_return_val = fwiThreshold_GT_32f_C1IR ( yPixel , p->srcStep, p->spare_roiSize , threshold ); if (api_return_val<0) throw api_return_val ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiThreshold_LT_32f_C1IR" : */ /* */ /* This functions steps through an ROI in a source buffer and compares */ /* source data to a specified threshold value. When the source data is */ /* lesser than the threshold value, the output data is set to the threshold */ /* value. */ /* */ /*--------------------------------------------------------------------------------*/ threshold = 0; api_return_val = fwiThreshold_LT_32f_C1IR ( yPixel , p->srcStep, p->spare_roiSize , threshold ); if (api_return_val<0) throw api_return_val ; yOffset++ ; if (yOffset == yhalf) { yAllow += p->y_len ; yOffset = -(yhalf + yplus) ; } xAllow = 0 ; xOffset = 0 ; for (int x=0 ; x < p->bor_width ; x++) { p->srcStep = 1 ; xPixel[0] = (Fw32f)(xAllow + xOffset * 2) ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiThreshold_GT_32f_C1IR" : */ /* */ /* This functions steps through an ROI in a source buffer and compares */ /* source data to a specified threshold value. When the source data is */ /* greater than the threshold value, the output data is set to the threshold */ /* value. */ /* */ /*--------------------------------------------------------------------------------*/ threshold = (Fw32f)(p->bor_width - 1) ; api_return_val = fwiThreshold_GT_32f_C1IR ( xPixel , p->srcStep, p->spare_roiSize , threshold ); if (api_return_val<0) throw api_return_val ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiThreshold_LT_32f_C1IR" : */ /* */ /* This functions steps through an ROI in a source buffer and compares */ /* source data to a specified threshold value. When the source data is */ /* lesser than the threshold value, the output data is set to the threshold */ /* value. */ /* */ /*--------------------------------------------------------------------------------*/ threshold = 0; api_return_val = fwiThreshold_LT_32f_C1IR ( xPixel , p->srcStep, p->spare_roiSize , threshold ); if (api_return_val<0) throw api_return_val ; p->srcStep = 3 ; int a = (int)((yPixel[0] * p->bor_width * 3)+ (xPixel[0]-1) * 3 ); /*--------------------------------------------------------------------------------*/ /* Calling API "fwiCopy_8u_C3R" : */ /* */ /* This functions steps through an ROI in a source buffer and copies the */ /* data in the source data on to the destination location. */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val = fwiCopy_8u_C3R ( &p->pSrc[a], p->srcStep, &p->pSrcDst[k] , p->srcStep , p->spare_roiSize ); if (api_return_val<0) throw api_return_val ; k = k + 3; xOffset++ ; if (xOffset == xhalf) { xAllow += p->x_len ; xOffset = -(xhalf + xplus) ; } } } free(xPixel) ; free(yPixel) ; TIME_FINISH(p) /* Stop Timer */ }
/*! ************************************************************************************* * \function process_emboss * * \brief * This function processes the opertation to emboss an image. * * ************************************************************************************* */ void process_emboss(st_API_parameters *p) { int api_return_val ; TIME_START /* Start Timer */ p->spare_roiSize.width = 1 ; p->spare_roiSize.height = 1 ; int k = 0 ; int sum_present = 0 ; int sum_next = 0 ; Fw8u threshold = 0 ; for(int y=1; y<p->bor_height; y++) { for(int x=0; x<= (p->bor_width) - 1; x++) { if (x == (p->bor_width ) - 1) { p->srcStep = 3 ; p->grey[0] = 128 ; p->grey[1] = 128 ; p->grey[2] = 128 ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiCopy_8u_C3R" : */ /* */ /* This functions steps through an ROI in a source buffer and copies the */ /* data in the source data on to the destination location. */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val = fwiCopy_8u_C3R (p->grey, p->srcStep , &p->pDst[0] + k , p->srcStep , p->spare_roiSize ); if (api_return_val<0) throw api_return_val ; k = k + 3; } else { p->srcStep = 1 ; sum_present = p->pSrcDst[k] + p->pSrcDst[k+1] + p->pSrcDst[k+2] ; sum_next = p->pSrcDst[k+3] + p->pSrcDst[k+4] + p->pSrcDst[k+5] ; p->grey[0] = 2 * (sum_present - sum_next) / 3 + 128 ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiThreshold_GT_8u_C1IR" : */ /* */ /* This functions steps through an ROI in a source buffer and compares */ /* source data to a specified threshold value. When the source data is */ /* greater than the threshold value, the output data is set to the threshold */ /* value. */ /* */ /*--------------------------------------------------------------------------------*/ threshold = 255 ; api_return_val = fwiThreshold_GT_8u_C1IR ( p->grey , p->srcStep , p->spare_roiSize , threshold ); if (api_return_val<0) throw api_return_val ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiThreshold_LT_8u_C1IR" : */ /* */ /* This functions steps through an ROI in a source buffer and compares */ /* source data to a specified threshold value. When the source data is */ /* lesser than the threshold value, the output data is set to the threshold */ /* value. */ /* */ /*--------------------------------------------------------------------------------*/ threshold = 0 ; api_return_val = fwiThreshold_LT_8u_C1IR ( p->grey , p->srcStep , p->spare_roiSize , threshold ); if (api_return_val<0) throw api_return_val ; p->grey[1] = p->grey[0] ; p->grey[2] = p->grey[0] ; p->srcStep = 3 ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiCopy_8u_C3R" : */ /* */ /* This functions steps through an ROI in a source buffer and copies the */ /* data in the source data on to the destination location. */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val = fwiCopy_8u_C3R (p->grey, p->srcStep , &p->pDst[0] + k , p->srcStep , p->spare_roiSize ); if (api_return_val<0) throw api_return_val ; k = k + 3; } } } p->srcStep = p->bor_width *3; p->spare_roiSize.width = p->bor_width ; p->spare_roiSize.height = p->bor_height ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiCopy_8u_C3R" : */ /* */ /* This functions steps through an ROI in a source buffer and copies the */ /* data in the source data on to the destination location. */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val = fwiCopy_8u_C3R (p->pDst, p->srcStep , p->pSrcDst , p->srcStep , p->spare_roiSize ); TIME_FINISH(p) /* Stop Timer */ if (api_return_val<0) throw api_return_val ; }
/*! ************************************************************************************* * \function process_deinterlace * * \brief * This function processes the opertation to deinterlace an image. * Deinterlace is useful for processing images from video capture cards. * When only the odd or even fields get captured, deinterlace can be used to * interpolate between the existing fields to correct this. * * ************************************************************************************* */ void process_deinterlace(st_API_parameters *p) { int api_return_val ; TIME_START /* Start Timer */ p->spare_roiSize.width = p->bor_width ; p->spare_roiSize.height = 1 ; int k = 0 ; Fw8u *up ; Fw8u *down ; up = (unsigned char*)malloc(p->bor_width * 3) ; down = (unsigned char*)malloc(p->bor_width * 3) ; for(int j=1; j<(p->bor_height -1); j++) { if (j % 2 == p->field) { /*--------------------------------------------------------------------------------*/ /* Calling API "fwiCopy_8u_C3R" : */ /* */ /* This functions steps through an ROI in a source buffer and copies the */ /* data in the source data on to the destination location. */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val = fwiCopy_8u_C3R (&p->pSrcDst[(j-1)*(p->bor_width * 3)], p->srcStep , up , p->srcStep , p->spare_roiSize ); if (api_return_val<0) throw api_return_val ; api_return_val = fwiCopy_8u_C3R (&p->pSrcDst[(j+1)*(p->bor_width * 3)], p->srcStep , down , p->srcStep , p->spare_roiSize ); if (api_return_val<0) throw api_return_val ; k = (j * p->bor_width * 3) ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiDivC_8u_C3IRSfs" : */ /* */ /* This function steps through an ROI in a source buffer and divides the */ /* source data by a constant value. The quotient is written back to the */ /* source location . */ /* */ /*--------------------------------------------------------------------------------*/ p->value[0] = 2; p->value[1] = 2; p->value[2] = 2; api_return_val = fwiDivC_8u_C3IRSfs (p->value , up , p->srcStep , p->spare_roiSize , p->scaleFactor ); if (api_return_val<0) throw api_return_val ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiDivC_8u_C3IRSfs" : */ /* */ /* This function steps through an ROI in a source buffer and divides the */ /* source data by a constant value. The quotient is written back to the */ /* source location . */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val =fwiDivC_8u_C3IRSfs (p->value , down , p->srcStep , p->spare_roiSize , p->scaleFactor ); if (api_return_val<0) throw api_return_val ; /*--------------------------------------------------------------------------------*/ /* Calling API "fwiAdd_8u_C3RSfs" : */ /* */ /* These functions step through ROIs in two source buffers and add the data */ /* in buffer 2 to the data in buffer 1. */ /* The result is written to the buffer 3 location. */ /* */ /*--------------------------------------------------------------------------------*/ api_return_val =fwiAdd_8u_C3RSfs ( up , p->srcStep , down , p->srcStep , &p->pSrcDst[k] , p->srcStep , p->spare_roiSize ,p->scaleFactor ); if (api_return_val<0) throw api_return_val ; } } free(up) ; free(down) ; TIME_FINISH(p) /* Stop Timer */ }