/** * To calculate the image vertical pixel differences R * * @param aImage [TAlgoImage] Image with Channel. * @param aPixelDiffR [TReal64*] Vertical pixel difference of Channel R. * @param aTestCoordinates [TAlgoImageTestCoordinates*] TestCoordinates. * * @return [TAlgoError] EErrorNone if the differences is computed successfully. */ TAlgoError CalculateImageVerticalDiff_R( const TAlgoImage* aImage, TReal64* aPixelDiffR, const TAlgoImageTestCoordinates* aTestCoordinates) { TUint32 width = 0; TUint32 height = 0; TUint32 index = 0; TUint32 counter = 0; *aPixelDiffR = 0; for (height = 0; height < aImage->iImageParams.iImageHeight; height++) { for (width = 0; width < aImage->iImageParams.iImageWidth; width++) { index = height * aImage->iImageParams.iImageWidth + width; if ( (index > aImage->iImageParams.iImageWidth) && (index - (height * aImage->iImageParams.iImageWidth) > aTestCoordinates->iStartIndexX) && (index - (height * aImage->iImageParams.iImageWidth) <= aTestCoordinates->iStartIndexX + aTestCoordinates->iPixelsToGrabX) && (height > aTestCoordinates->iStartIndexY) && (height <= aTestCoordinates->iStartIndexY + aTestCoordinates->iPixelsToGrabY) ) { *aPixelDiffR += ABS(aImage->iImageData.iRChannel[index] - aImage->iImageData.iRChannel[index-aImage->iImageParams.iImageWidth]); counter++; } } } ALGO_Log_1("fct %s\n", __FUNCTION__); ALGO_Log_1("counter = %d\n", counter); ALGO_Log_1("iPixelsToGrabX * iPixelsToGrabY = %d\n", aTestCoordinates->iPixelsToGrabX * aTestCoordinates->iPixelsToGrabY); ALGO_Log_2("iPixelsToGrabX = %d iPixelsToGrabY = %d\n", aTestCoordinates->iPixelsToGrabX, aTestCoordinates->iPixelsToGrabY); return EErrorNone; }
TAlgoError GetLumaOn_R_Channel_And_Normalize( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable ) { TUint32 index = 0; TReal64 Avg_Disable = 0; TReal64 Avg_Enable = 0; TReal64 Average = 0; TReal64 Avg_EnableModified = 0; TUint32 width = 0; TUint32 height = 0; TAlgoError errorCode = EErrorNone; errorCode = GetLumaOn_R_Channel(aImageEffectDisable, aImageEffectEnable,&Avg_Disable,&Avg_Enable); if( EErrorNone != errorCode) { return EErrorImageNotRelevant; } Average = (Avg_Disable/Avg_Enable); ALGO_Log_1("Avg_Disable/Avg_Enable = %1.6lf \n", (double)(Average)); // normalize image width = aImageEffectDisable->iImageParams.iImageWidth; height = aImageEffectDisable->iImageParams.iImageHeight; if(Average <= 1.0) { for( index=0; index<(width * height); index++) { aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(Average* aImageEffectEnable->iImageData.iRChannel[index]); Avg_EnableModified += aImageEffectEnable->iImageData.iRChannel[index]; } } else { TUint16 tmp_Value=0; for( index=0; index<(width * height); index++) { tmp_Value = (TUint16)(Average* aImageEffectEnable->iImageData.iRChannel[index]); if(0xFF >= tmp_Value) { aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)tmp_Value; } else { // clip aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)0xFF; } Avg_EnableModified += aImageEffectEnable->iImageData.iRChannel[index]; } } Avg_EnableModified = Avg_EnableModified/(width * height); ALGO_Log_1("GetLumaOn_R_Channel_And_Normalize Avg_EnableModified %1.6lf \n", Avg_EnableModified); return EErrorNone; }
TAlgoError GetLumaOn_R_Channel( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, TReal64 *p_Avg_Disable, TReal64 *p_Avg_Enable ) { TUint32 index = 0; TReal64 Avg_Disable = 0; TReal64 Avg_Enable = 0; TReal64 Average = 0; TUint32 width = 0; TUint32 height = 0; *p_Avg_Disable = 0xff/2; *p_Avg_Enable = 0xff/2; if( (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight) != (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight) ) { return EErrorImageNotRelevant; } width = aImageEffectDisable->iImageParams.iImageWidth; height = aImageEffectDisable->iImageParams.iImageHeight; //Calculating the average of luma components of both images for normalization. for( index=0; index<(width * height); index++) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); Avg_Disable += aImageEffectDisable->iImageData.iRChannel[index]; } Avg_Disable = Avg_Disable/(width * height); ALGO_Log_1("GetLumaOn_R_Channel_And_Normalize Avg_Disable %1.6lf \n", Avg_Disable); *p_Avg_Disable = Avg_Disable; for( index=0; index<(width * height); index++) { aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); Avg_Enable += aImageEffectEnable->iImageData.iRChannel[index]; } Avg_Enable = Avg_Enable/(width * height); ALGO_Log_1("GetLumaOn_R_Channel_And_Normalize Avg_Enable %1.6lf \n", Avg_Enable); *p_Avg_Enable = Avg_Enable; return EErrorNone; }
/** * Validation Metric for the Black and White Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricBlackAndWhiteEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TAlgoError errorCode = EErrorNotValidated; TReal64 tolerance = 0; TReal64 R_Avg_Im1 = 0; TReal64 G_Avg_Im1 = 0; TReal64 B_Avg_Im1 = 0; TReal64 R_Avg_Im2 = 0; TReal64 G_Avg_Im2 = 0; TReal64 B_Avg_Im2 = 0; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); Channel_Average( aImageEffectDisable, &(aMetricParams->iTestCoordinates), &R_Avg_Im1, &G_Avg_Im1, &B_Avg_Im1 ); Channel_Average( aImageEffectEnable, &(aMetricParams->iTestCoordinates), &R_Avg_Im2, &G_Avg_Im2, &B_Avg_Im2 ); //ALGO_Log_1("R_Average %f\n",R_Avg_Im1); //ALGO_Log_1("G_Average %f\n",G_Avg_Im1); //ALGO_Log_1("B_Average %f\n",B_Avg_Im1); tolerance = BLACKANDWHITE_THRESHOLD + ((aMetricParams->iErrorTolerance.iErrorToleranceR * BLACKANDWHITE_THRESHOLD)/100); if( (ABS(R_Avg_Im2 - G_Avg_Im2) <= tolerance)&& (ABS(G_Avg_Im2 - B_Avg_Im2) <= tolerance) && (ABS(B_Avg_Im2 - R_Avg_Im2) <= tolerance) ) //if(R_Avg_Im2 == G_Avg_Im2 == B_Avg_Im2) { ALGO_Log_1("R_Average2 %f\n",R_Avg_Im2); ALGO_Log_1("G_Average2 %f\n",G_Avg_Im2); ALGO_Log_1("B_Average2 %f\n",B_Avg_Im2); ALGO_Log_2("ABS(R_Avg_Im2 - G_Avg_Im2) %f, tolerance %f\n", ABS(R_Avg_Im2 - G_Avg_Im2), tolerance); ALGO_Log_2("ABS(G_Avg_Im2 - B_Avg_Im2) %f, tolerance %f\n", ABS(G_Avg_Im2 - B_Avg_Im2), tolerance); ALGO_Log_2("ABS(B_Avg_Im2 - R_Avg_Im2) %f, tolerance %f\n", ABS(B_Avg_Im2 - R_Avg_Im2), tolerance); ALGO_Log_0("Metric BlackAndWhiteEffect : EErrorNone\n"); errorCode = EErrorNone; } else { ALGO_Log_1("R_Average2 %f\n",R_Avg_Im2); ALGO_Log_1("G_Average2 %f\n",G_Avg_Im2); ALGO_Log_1("B_Average2 %f\n",B_Avg_Im2); ALGO_Log_2("ABS(R_Avg_Im2 - G_Avg_Im2) %f, tolerance %f\n", ABS(R_Avg_Im2 - G_Avg_Im2), tolerance); ALGO_Log_2("ABS(G_Avg_Im2 - B_Avg_Im2) %f, tolerance %f\n", ABS(G_Avg_Im2 - B_Avg_Im2), tolerance); ALGO_Log_2("ABS(B_Avg_Im2 - R_Avg_Im2) %f, tolerance %f\n", ABS(B_Avg_Im2 - R_Avg_Im2), tolerance); ALGO_Log_0("Metric BlackAndWhiteEffect : EErrorNotValidated\n"); errorCode = EErrorNotValidated; } return errorCode; }
// Histogram Draw Function TAlgoError DrawHistogram( TUint32* aHistogram, TUint32 aMaxValue ) { TUint32 loop1 =0; TUint32 loop2 = 0; ALGO_Log_0("Array Element Value in Element Histogram \n"); ALGO_Log_0("------------- ---------------- --------- \n"); for ( loop1 =0; loop1 < aMaxValue; loop1 = loop1+8) { ALGO_Log_1("%7d", loop1); ALGO_Log_1("%19d ", aHistogram[loop1]); for (loop2 = 0; loop2 < aHistogram[loop1]; loop2 = loop2+8){ ALGO_Log_0("*"); } ALGO_Log_0("\n"); } ALGO_Log_0("\n\n"); return EErrorNone; }
/** * Validation Metric for the Spatial Similarity Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams] The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricRotationEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TAlgoError errorCode = EErrorNone ; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); errorCode = GetLumaOn_R_Channel_And_Normalize(aImageEffectDisable, aImageEffectEnable); if(errorCode!= EErrorNone) { return EErrorNotValidated; } if (EType0degreesRotation == aMetricParams->iType) //For 0 degrees Rotation Image Metrices. return ValidationMetric0degreesRotationEffect(aImageEffectDisable,aImageEffectEnable,aMetricParams); else if (EType90degreesRotation == aMetricParams->iType) //For 90 degrees Rotation Image Metrices. return ValidationMetric90degreesRotationEffect(aImageEffectDisable,aImageEffectEnable,aMetricParams); else if (EType180degreesRotation == aMetricParams->iType) //For 180 degrees Rotation Image Metrices. return ValidationMetric180degreesRotationEffect(aImageEffectDisable,aImageEffectEnable,aMetricParams); else if (EType270degreesRotation == aMetricParams->iType) //For 270 degrees Rotation Image Metrices. return ValidationMetric270degreesRotationEffect(aImageEffectDisable,aImageEffectEnable,aMetricParams); return EErrorNone; }
/** * Validation Metric for the ExposurePreset. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricExposurePreset( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TAlgoParamExposurePreset *paramExposurePreset = (TAlgoParamExposurePreset*)aMetricParams->iParams; TAlgoError error = EErrorNotValidated; TUint32 i = 0; TUint32 j = 0; TUint32 temp = 0; TUint32 medianArrayDisable[256] = {0}; TUint32 medianArrayEnable[256] = {0}; TUint32 medianDisable = 0; TUint32 medianEnable = 0; TUint32 index = 0; TReal64 Avg_Disable = 0; TReal64 Avg_Enable = 0; TReal64 diff=0, diffPercentage=0; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; TUint32 offset = (aImageEffectDisable->iImageParams.iImageWidth - aMetricParams->iTestCoordinates.iPixelsToGrabX); ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); ALGO_Log_3("ExposurePreset Metric : iExpoPreset_1 %d, iExpoPreset_2 %d, iTolerance %d\n\n", paramExposurePreset->iExpoPreset_1, paramExposurePreset->iExpoPreset_2, paramExposurePreset->iTolerance); //Getting the luma component for both images in the R Channel. for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); medianArrayDisable[aImageEffectDisable->iImageData.iRChannel[index]]++; medianArrayEnable[aImageEffectEnable->iImageData.iRChannel[index]]++; } //Calculating the average of luma components of both images. index = startingOffset; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabY; i++ ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabX; j++) { Avg_Disable = Avg_Disable + aImageEffectDisable->iImageData.iRChannel[index]; Avg_Enable = Avg_Enable + aImageEffectEnable->iImageData.iRChannel[index]; index++; } index = index + offset; } Avg_Disable = Avg_Disable/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); Avg_Enable = Avg_Enable/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); //Calculating the median temp = 0; for( i=0; i<256; i++ ) { temp = temp + medianArrayDisable[i]; if(temp > (aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth)/2) { break; } } medianDisable = i; temp = 0; for( i=0; i<256; i++ ) { temp = temp + medianArrayEnable[i]; if(temp > (aImageEffectEnable->iImageParams.iImageHeight * aImageEffectEnable->iImageParams.iImageWidth)/2) { break; } } medianEnable = i; //Doing median Check if(((ABS(Avg_Disable - medianDisable)) < 10) && ((ABS(Avg_Enable - medianEnable)) < 10)) { ALGO_Log_0("Exposure Preset Metric : Median Check PASSED\n"); ALGO_Log_2("Exposure Preset Metric : Average Disable = %.3f, Median Disable = %d\n", Avg_Disable, medianDisable); ALGO_Log_2("Exposure Preset Metric : Average Enable = %.3f, Median Enable = %d\n\n", Avg_Enable, medianEnable); } else { ALGO_Log_0("Exposure Preset Metric : Median Check FAILED\n"); ALGO_Log_2("Exposure Preset Metric : Average Disable = %.3f, Median Disable = %d\n", Avg_Disable, medianDisable); ALGO_Log_2("Exposure Preset Metric : Average Enable = %.3f, Median Enable = %d\n\n", Avg_Enable, medianEnable); } diff = ABS(Avg_Disable - Avg_Enable) ; diffPercentage = (diff / 256)*100; ALGO_Log_2("Avg_Disable = %.3f, Avg_Enable = %.3f\n", Avg_Disable, Avg_Enable); ALGO_Log_3("diff = %.3f, diffPercentage = %.3f, tolerance = %d\n", diff, diffPercentage, paramExposurePreset->iTolerance); if( diffPercentage < paramExposurePreset->iTolerance ) { error = EErrorNone; } else { error = EErrorNotValidated; ALGO_Log_2("diffPercentage = %.1f, iTolerance = %d\n", diffPercentage, paramExposurePreset->iTolerance); ALGO_Log_1("Error in %s\n", __FUNCTION__); } return error; }
/** * Validation Metric for the Contrast Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricContrastEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { #if 1 TUint32 index = 0; TUint32 x = 0; TUint32 y = 0; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; TUint32 offset = (aImageEffectDisable->iImageParams.iImageWidth - aMetricParams->iTestCoordinates.iPixelsToGrabX); TUint8 *iR = aImageEffectDisable->iImageData.iRChannel + startingOffset; TUint8 *oR = aImageEffectEnable->iImageData.iRChannel + startingOffset; //TInt32 DiffInput = 0, DiffOutput = 0; // don't use TInt32 but TReal64 as for big images we can have overflow TReal64 DiffInput = 0, DiffOutput = 0; TReal64 SDInput = 0, SDOutput = 0, SDDiff = 0; TReal64 tolerance = 0; TUint32 mean_input = 0, mean_output = 0; TAlgoParamContrast *paramContrast = (TAlgoParamContrast*)aMetricParams->iParams; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); ALGO_Log_2("Contrast Metric : iPrContrast_1 %d, iPrContrast_2 %d\n\n", paramContrast->iPrContrast_1, paramContrast->iPrContrast_2); for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++ ) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); } //ALGO_Log_2("LumaInputMean = %10d, LumaOutputMean = %10d\n", InputMean, OutputMean); mean_input = 0; mean_output = 0; iR = aImageEffectDisable->iImageData.iRChannel + startingOffset; oR = aImageEffectEnable->iImageData.iRChannel + startingOffset; for(y=0; y < aMetricParams->iTestCoordinates.iPixelsToGrabY - 1; y++) { for (x=0; x < aMetricParams->iTestCoordinates.iPixelsToGrabX - 1; x++) { mean_input += *iR; mean_output += *oR; iR++; oR++; } iR += offset; oR += offset; } mean_input = mean_input /(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); mean_output = mean_output /(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); ALGO_Log_2("mean_input = %d, mean_output = %d\n", mean_input, mean_output); iR = aImageEffectDisable->iImageData.iRChannel + startingOffset; oR = aImageEffectEnable->iImageData.iRChannel + startingOffset; for(y=0; y < aMetricParams->iTestCoordinates.iPixelsToGrabY - 1; y++) { for (x=0; x < aMetricParams->iTestCoordinates.iPixelsToGrabX - 1; x++) { DiffInput = DiffInput + ((*iR - mean_input) * (*iR - mean_input)); DiffOutput = DiffOutput + ((*oR - mean_output) * (*oR - mean_output)); iR++; oR++; } iR += offset; oR += offset; } SDInput = SQUAREROOT(DiffInput/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY)); SDOutput = SQUAREROOT(DiffOutput/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY)); ALGO_Log_2("SDInput = %10f, SDOutput = %10f\n", SDInput, SDOutput); tolerance = (aMetricParams->iErrorTolerance.iErrorToleranceR * CONTRAST_THRESHOLD)/100; ALGO_Log_2("CONTRAST_THRESHOLD = %d, (CONTRAST_THRESHOLD - tolerance) = %10f\n", CONTRAST_THRESHOLD, (CONTRAST_THRESHOLD - tolerance)); if(paramContrast->iPrContrast_1 < paramContrast->iPrContrast_2) { SDDiff = SDOutput - SDInput; } else { SDDiff = SDInput - SDOutput; } ALGO_Log_1("SDDiff = %10f\n", SDDiff); if( SDDiff > (CONTRAST_THRESHOLD - tolerance)) { return EErrorNone; } else { return EErrorNotValidated; } #else TReal64 R_Avg_Im1 = 0; TReal64 G_Avg_Im1 = 0; TReal64 B_Avg_Im1 = 0; TReal64 Intensity_Im1 = 0; TReal64 R_Avg_Im2 = 0; TReal64 G_Avg_Im2 = 0; TReal64 B_Avg_Im2 = 0; TReal64 Intensity_Im2 = 0; Channel_Average( aImageEffectDisable, &(aMetricParams->iTestCoordinates), &R_Avg_Im1, &G_Avg_Im1, &B_Avg_Im1 ); Channel_Average( aImageEffectEnable, &(aMetricParams->iTestCoordinates), &R_Avg_Im2, &G_Avg_Im2, &B_Avg_Im2 ); Intensity_Im1 = (R_Avg_Im1 + G_Avg_Im1 + B_Avg_Im1)/3.255; Intensity_Im2 = (R_Avg_Im2 + G_Avg_Im2 + B_Avg_Im2)/3.255; ALGO_Log_2("Intensity_Im1 = %10f, Intensity_Im2 %10f\n", Intensity_Im1, Intensity_Im2); if( Intensity_Im1 > Intensity_Im2) { return EErrorNone; } else { return EErrorNotValidated; } #endif }
/** * Validation Metric for the Auto Focus Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams] The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricAutoFocusEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TReal64 HorizPixelDiffEffectEnableR = 0; //TReal64 HorizPixelDiffEffectEnableG = 0; //TReal64 HorizPixelDiffEffectEnableB = 0; TReal64 VertPixelDiffEffectEnableR = 0; //TReal64 VertPixelDiffEffectEnableG = 0; //TReal64 VertPixelDiffEffectEnableB = 0; TReal64 HorizPixelDiffEffectDisableR = 0; //TReal64 HorizPixelDiffEffectDisableG = 0; //TReal64 HorizPixelDiffEffectDisableB = 0; TReal64 VertPixelDiffEffectDisableR = 0; //TReal64 VertPixelDiffEffectDisableG = 0; //TReal64 VertPixelDiffEffectDisableB = 0; //TReal64 HorizPixelDiffEffectEnableLuminance = 0; //TReal64 VertPixelDiffEffectEnableLuminance = 0; //TReal64 HorizPixelDiffEffectDisableLuminance = 0; //TReal64 VertPixelDiffEffectDisableLuminance = 0; //TReal64 HorizPixelDiffEffectEnableLuminanceFullImage = 0; //TReal64 VertPixelDiffEffectEnableLuminanceFullImage = 0; //TReal64 HorizPixelDiffEffectDisableLuminanceFullImage = 0; //TReal64 VertPixelDiffEffectDisableLuminanceFullImage = 0; TReal64 tolerance = 0; TReal64 threshold = 0; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); ALGO_Log_2("iPixelsToGrabX = %d, iPixelsToGrabY = %d\n", aMetricParams->iTestCoordinates.iPixelsToGrabX, aMetricParams->iTestCoordinates.iPixelsToGrabY); /* CalculateImageHorizontalDiff( aImageEffectEnable, &HorizPixelDiffEffectEnableR, &HorizPixelDiffEffectEnableG, &HorizPixelDiffEffectEnableB, &HorizPixelDiffEffectEnableLuminance, &aMetricParams->iTestCoordinates ); CalculateImageVerticalDiff( aImageEffectEnable, &VertPixelDiffEffectEnableR, &VertPixelDiffEffectEnableG, &VertPixelDiffEffectEnableB, &VertPixelDiffEffectEnableLuminance, &aMetricParams->iTestCoordinates ); CalculateImageHorizontalDiff( aImageEffectDisable, &HorizPixelDiffEffectDisableR, &HorizPixelDiffEffectDisableG, &HorizPixelDiffEffectDisableB, &HorizPixelDiffEffectDisableLuminance, &aMetricParams->iTestCoordinates ); CalculateImageVerticalDiff( aImageEffectDisable, &VertPixelDiffEffectDisableR, &VertPixelDiffEffectDisableG, &VertPixelDiffEffectDisableB, &VertPixelDiffEffectDisableLuminance, &aMetricParams->iTestCoordinates ); ALGO_Log_1("HorizPixelDiffEffectEnableLuminance/HorizPixelDiffEffectDisableLuminance = %1.2lf\n\n", (double)(HorizPixelDiffEffectEnableLuminance/HorizPixelDiffEffectDisableLuminance)); ALGO_Log_1("VertPixelDiffEffectEnableLuminance/VertPixelDiffEffectDisableLuminance = %1.2lf\n\n", (double)(VertPixelDiffEffectEnableLuminance/VertPixelDiffEffectDisableLuminance)); tolerance = ((aMetricParams->iErrorTolerance.iErrorToleranceR) * (AUTO_FOCUS_THRESHOLD - 1))/100; threshold = AUTO_FOCUS_THRESHOLD - tolerance; ALGO_Log_1("threshold = %f\n", threshold); if(((HorizPixelDiffEffectEnableLuminance/HorizPixelDiffEffectDisableLuminance) > threshold) && ((VertPixelDiffEffectEnableLuminance/VertPixelDiffEffectDisableLuminance) > threshold)) { return EErrorNone; } else { return EErrorNotValidated; } */ { TAlgoError errorCode = EErrorNone ; errorCode = GetLumaOn_R_Channel_And_Normalize(aImageEffectDisable, aImageEffectEnable); if(errorCode!= EErrorNone) { return EErrorNotValidated; } } CalculateImageHorizontalDiff_R( aImageEffectEnable, &HorizPixelDiffEffectEnableR, &aMetricParams->iTestCoordinates ); CalculateImageVerticalDiff_R( aImageEffectEnable, &VertPixelDiffEffectEnableR, &aMetricParams->iTestCoordinates ); CalculateImageHorizontalDiff_R( aImageEffectDisable, &HorizPixelDiffEffectDisableR, &aMetricParams->iTestCoordinates ); CalculateImageVerticalDiff_R( aImageEffectDisable, &VertPixelDiffEffectDisableR, &aMetricParams->iTestCoordinates ); ALGO_Log_1("HorizPixelDiffEffectDisableR = %1.2lf\n\n", (double)(HorizPixelDiffEffectDisableR)); ALGO_Log_1("VertPixelDiffEffectDisableR = %1.2lf\n\n", (double)(VertPixelDiffEffectDisableR)); ALGO_Log_1("HorizPixelDiffEffectEnableR = %1.2lf\n\n", (double)(HorizPixelDiffEffectEnableR)); ALGO_Log_1("VertPixelDiffEffectEnableR = %1.2lf\n\n", (double)(VertPixelDiffEffectEnableR)); ALGO_Log_1("HorizPixelDiffEffectEnableR/HorizPixelDiffEffectDisableR = %1.2lf\n\n", (double)(HorizPixelDiffEffectEnableR/HorizPixelDiffEffectDisableR)); ALGO_Log_1("VertPixelDiffEffectEnableR/VertPixelDiffEffectDisableR = %1.2lf\n\n", (double)(VertPixelDiffEffectEnableR/VertPixelDiffEffectDisableR)); tolerance = ((aMetricParams->iErrorTolerance.iErrorToleranceR) * (AUTO_FOCUS_THRESHOLD - 1))/100; threshold = AUTO_FOCUS_THRESHOLD - tolerance; ALGO_Log_1("AUTO_FOCUS_THRESHOLD = %f\n", AUTO_FOCUS_THRESHOLD); ALGO_Log_1("tolerance_param in percent = %d\n", aMetricParams->iErrorTolerance.iErrorToleranceR); ALGO_Log_1("threshold = %f\n", threshold); if(((HorizPixelDiffEffectEnableR/HorizPixelDiffEffectDisableR) > threshold) && ((VertPixelDiffEffectEnableR/VertPixelDiffEffectDisableR) > threshold)) { return EErrorNone; } else { return EErrorNotValidated; } }
TAlgoError ValidationMetric270degreesRotationEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TUint32 i = 0; TUint32 j = 0; TUint32 indexDisable =0; TUint32 indexEnable =0; TInt32 error1 = 0; TInt32 error_mean_row = 0, error_mean_col = 0, error_mean_row_total = 0, error_mean_col_total = 0; TInt32 deviationCol = 0; TInt32 deviationRow = 0; TUint32 colonimg1 = 0; TUint32 colonimg2 = 0; TUint32 rowimg1 = 0; TUint32 rowimg2 = 0; #ifdef ROTATION_OLD_WAY TReal64 toleranceCol = 0; TReal64 toleranceRow = 0; #endif TInt32 colonDiff = 0; TInt32 rowDiff = 0; TUint32 startingOffsetDisable = 0, startingOffsetEnable = 0; TUint32 EnableWidthWorking = 0; TUint32 EnableHeightWorking = 0; ALGO_Log_1("entering rotation %s\n", __FUNCTION__); ALGO_Log_2("iStartIndexX %d , iStartIndexY %d\n", aMetricParams->iTestCoordinates.iStartIndexX, aMetricParams->iTestCoordinates.iStartIndexY); ALGO_Log_2("iPixelsToGrabX %d , iPixelsToGrabY %d\n", aMetricParams->iTestCoordinates.iPixelsToGrabX, aMetricParams->iTestCoordinates.iPixelsToGrabY); ALGO_Log_4("Disable width x height = %d x %d, stride %d, sliceheight %d\n", aImageEffectDisable->iImageParams.iImageWidth, aImageEffectDisable->iImageParams.iImageHeight, aImageEffectDisable->iImageParams.iImageStride, aImageEffectDisable->iImageParams.iImageSliceHeight); ALGO_Log_4("Enable width x height = %d x %d, stride %d, sliceheight %d\n", aImageEffectEnable->iImageParams.iImageWidth, aImageEffectEnable->iImageParams.iImageHeight, aImageEffectEnable->iImageParams.iImageStride, aImageEffectEnable->iImageParams.iImageSliceHeight); EnableWidthWorking = aImageEffectDisable->iImageParams.iImageHeight; ALGO_Log_1("EnableWidthWorking %d\n", EnableWidthWorking); EnableHeightWorking = aImageEffectDisable->iImageParams.iImageWidth; ALGO_Log_1("EnableHeightWorking %d\n", EnableHeightWorking); startingOffsetDisable = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; startingOffsetEnable = EnableWidthWorking * (EnableHeightWorking - aMetricParams->iTestCoordinates.iStartIndexX -1) + aMetricParams->iTestCoordinates.iStartIndexY; error_mean_col = 0; error_mean_col_total = 0; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabX; i++ ) { indexDisable = startingOffsetDisable;// First Column. indexEnable = startingOffsetEnable;// row. for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabY; j++) { colonimg1 = colonimg1 + aImageEffectDisable->iImageData.iRChannel[indexDisable]; rowimg2 = rowimg2 + aImageEffectEnable->iImageData.iRChannel[indexEnable]; indexDisable = indexDisable + aImageEffectDisable->iImageParams.iImageWidth; indexEnable++; } colonimg1 = colonimg1/aMetricParams->iTestCoordinates.iPixelsToGrabX; rowimg2 = rowimg2/aMetricParams->iTestCoordinates.iPixelsToGrabX; rowDiff = colonimg1 - rowimg2; error1 = ABS(rowDiff); error_mean_col_total += error1; if(error1 > ROTATION_THRESHOLD) { #ifdef ROTATION_OLD_WAY ALGO_Log_3("\t\t deviationCol++, w_i=%d, error1 = %d > %d = ROTATION_THRESHOLD\n", i, error1, ROTATION_THRESHOLD); #endif deviationCol++; error_mean_col += error1; } colonimg1 = 0; rowimg2 = 0; startingOffsetDisable++; // Next Column startingOffsetEnable = startingOffsetEnable - EnableWidthWorking; // Next Row } if(deviationCol != 0) { error_mean_col = error_mean_col / deviationCol; } error_mean_col_total = error_mean_col_total / i; startingOffsetDisable = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; startingOffsetEnable = EnableWidthWorking * (EnableHeightWorking - aMetricParams->iTestCoordinates.iStartIndexX - 1) + aMetricParams->iTestCoordinates.iStartIndexY; error_mean_row = 0; error_mean_row_total = 0; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabY; i++ ) { indexDisable = startingOffsetDisable;// First Row. indexEnable = startingOffsetEnable;// Column. for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabX; j++) { rowimg1 = rowimg1 + aImageEffectDisable->iImageData.iRChannel[indexDisable]; colonimg2 = colonimg2 + aImageEffectEnable->iImageData.iRChannel[indexEnable]; indexDisable ++; indexEnable = indexEnable - EnableWidthWorking; } rowimg1 = rowimg1/aMetricParams->iTestCoordinates.iPixelsToGrabY; colonimg2 = colonimg2/aMetricParams->iTestCoordinates.iPixelsToGrabY; colonDiff = colonimg2 - rowimg1; error1 = ABS(colonDiff); error_mean_row_total += error1; if(error1 > ROTATION_THRESHOLD) { #ifdef ROTATION_OLD_WAY ALGO_Log_3("\t\t deviationRow++, h_i=%d, error1 = %d > %d = ROTATION_THRESHOLD\n", i, error1, ROTATION_THRESHOLD); #endif deviationRow++; error_mean_row += error1; } rowimg1 = 0; colonimg2 = 0; startingOffsetDisable = startingOffsetDisable + aImageEffectDisable->iImageParams.iImageWidth; // Next Row startingOffsetEnable++; // Column } if(deviationRow != 0) { error_mean_row = error_mean_row / deviationRow; } error_mean_row_total = error_mean_row_total / i; #ifdef ROTATION_OLD_WAY toleranceCol = ( aMetricParams->iErrorTolerance.iErrorToleranceR * aMetricParams->iTestCoordinates.iPixelsToGrabX )/100; toleranceRow = ( aMetricParams->iErrorTolerance.iErrorToleranceR * aMetricParams->iTestCoordinates.iPixelsToGrabY )/100; ALGO_Log_4("deviationCol = %10d, deviationRow = %10d, toleranceCol = %10f, toleranceRow = %10f\n", deviationCol, deviationRow, toleranceCol, toleranceRow); ALGO_Log_3("error_mean_col = %d, error_mean_row = %d, ROTATION_THRESHOLD = %d\n", error_mean_col, error_mean_row, ROTATION_THRESHOLD); if((deviationCol <= toleranceCol)&&(deviationRow <= toleranceRow)) { return EErrorNone; } else { return EErrorNotValidated;; } #else ALGO_Log_3("error_mean_col_total = %d, error_mean_row_total = %d, ROTATION_THRESHOLD_TOTAL = %d\n", error_mean_col_total, error_mean_row_total, ROTATION_THRESHOLD_TOTAL); if((error_mean_col_total <= ROTATION_THRESHOLD_TOTAL)&&(error_mean_row_total <= ROTATION_THRESHOLD_TOTAL)) { return EErrorNone; } else { return EErrorNotValidated;; } #endif }
/** * Validation Metric for the Negative Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams] The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricNegativeEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { #if 1 TUint32 i = 0; TUint32 j = 0; TUint32 index = 0; TUint32 deviation = 0; TReal64 tolerance = 0; TReal64 deltaR = 0; TReal64 deltaG = 0; TReal64 deltaB = 0; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; TUint32 offset = (aImageEffectDisable->iImageParams.iImageWidth - aMetricParams->iTestCoordinates.iPixelsToGrabX); ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); index = startingOffset; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabY; i++ ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabX; j++) { deltaR = ABS((255 - aImageEffectEnable->iImageData.iRChannel[index]) - (aImageEffectDisable->iImageData.iRChannel[index])); deltaG = ABS((255 - aImageEffectEnable->iImageData.iGChannel[index]) - (aImageEffectDisable->iImageData.iGChannel[index])); deltaB = ABS((255 - aImageEffectEnable->iImageData.iBChannel[index]) - (aImageEffectDisable->iImageData.iBChannel[index])); if((deltaR > NEGATIVE_THRESHOLD) || (deltaG > NEGATIVE_THRESHOLD) || (deltaB > NEGATIVE_THRESHOLD)) { deviation++; } index++; } index = index + offset; } tolerance = ( aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY * aMetricParams->iErrorTolerance.iErrorToleranceR ) / 100; ALGO_Log_2("deviation = %d, Tolerance = %f\n", deviation, tolerance); if(deviation <= (tolerance)) { return EErrorNone; } else { return EErrorNotValidated; } #else //TUint32 loop = 0; TReal64 R_Avg_Im1 = 0; TReal64 G_Avg_Im1 = 0; TReal64 B_Avg_Im1 = 0; TReal64 R_Avg_Im2 = 0; TReal64 G_Avg_Im2 = 0; TReal64 B_Avg_Im2 = 0; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); Channel_Average( aImageEffectDisable, &(aMetricParams->iTestCoordinates), &R_Avg_Im1, &G_Avg_Im1, &B_Avg_Im1 ); Channel_Average( aImageEffectEnable, &(aMetricParams->iTestCoordinates), &R_Avg_Im2, &G_Avg_Im2, &B_Avg_Im2 ); if(((R_Avg_Im1 < (aImageEffectDisable->iImageParams.iBitMaxR/2 - aMetricParams->iMetricRange.iRangeR)) || (R_Avg_Im1 > (aImageEffectDisable->iImageParams.iBitMaxR/2 + aMetricParams->iMetricRange.iRangeR))) && ((G_Avg_Im1 < (aImageEffectDisable->iImageParams.iBitMaxG/2 - aMetricParams->iMetricRange.iRangeG)) || (G_Avg_Im1 > (aImageEffectDisable->iImageParams.iBitMaxG/2 + aMetricParams->iMetricRange.iRangeG))) && ((B_Avg_Im1 < (aImageEffectDisable->iImageParams.iBitMaxB/2 - aMetricParams->iMetricRange.iRangeB)) || (B_Avg_Im1 > (aImageEffectDisable->iImageParams.iBitMaxB/2 + aMetricParams->iMetricRange.iRangeB)))) { if((ABS(R_Avg_Im1 - (aImageEffectDisable->iImageParams.iBitMaxR - R_Avg_Im2)) <= aMetricParams->iErrorTolerance.iErrorToleranceR ) && (ABS(G_Avg_Im1 - (aImageEffectDisable->iImageParams.iBitMaxG - G_Avg_Im2)) <= aMetricParams->iErrorTolerance.iErrorToleranceG ) && (ABS(B_Avg_Im1 - (aImageEffectDisable->iImageParams.iBitMaxB - B_Avg_Im2)) <= aMetricParams->iErrorTolerance.iErrorToleranceB )) //if((R_Avg_Im1 == 31 - R_Avg_Im2) & (G_Avg_Im1 == 63 - G_Avg_Im2) & (B_Avg_Im1 == 31 - B_Avg_Im2)) { return EErrorNone; } else { return EErrorNotValidated; } } else { return EErrorImageNotRelevant; } #endif }
/** * Validation Metric for the Solarize Effect (basic). * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricSolarizeEffect_basic( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TUint32 index = 0; TReal64 negTolerance = 0; TReal64 posTolerance = 0; TInt32 colorBar_NbColon = 8; TInt32 colorBar_ColonWidth = 0; TUint8 disableFirstColon_white_PixelValue = 0, enableFirstColon_white_PixelValue = 0; TUint8 disableLastColon_black_PixelValue = 0, enableLastColon_black_PixelValue = 0; for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++ ) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); } if(aMetricParams->iTestCoordinates.iPixelsToGrabX != aImageEffectDisable->iImageParams.iImageWidth) { ALGO_Log_0("Error, need to work on the whole image (color bar) Width \n"); return EErrorNotValidated; } if(aMetricParams->iTestCoordinates.iPixelsToGrabY != aImageEffectDisable->iImageParams.iImageHeight) { ALGO_Log_0("Error, need to work on the whole image (color bar) Height \n"); return EErrorNotValidated; } if( (aMetricParams->iTestCoordinates.iStartIndexY != 0) || (aMetricParams->iTestCoordinates.iStartIndexX != 0) ) { ALGO_Log_0("Error, need to work on the whole image (color bar) StartIndex\n"); return EErrorNotValidated; } colorBar_ColonWidth = aImageEffectDisable->iImageParams.iImageWidth / colorBar_NbColon; // middle of thh colon and middle of the height disableFirstColon_white_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableFirstColon_white_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableLastColon_black_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*(2*colorBar_NbColon-1)/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableLastColon_black_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*(2*colorBar_NbColon-1)/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; ALGO_Log_1("disableFirstColon_white_PixelValue = %d\n", disableFirstColon_white_PixelValue); ALGO_Log_1("enableFirstColon_white_PixelValue = %d\n", enableFirstColon_white_PixelValue); negTolerance = SOLARIZE_CHECK_NEG_THRESHOLD - ((SOLARIZE_CHECK_NEG_THRESHOLD * aMetricParams->iErrorTolerance.iErrorToleranceR)/100); ALGO_Log_1("negTolerance = %10f\n", negTolerance); ALGO_Log_1("disableLastColon_black_PixelValue = %d\n", disableLastColon_black_PixelValue); ALGO_Log_1("enableLastColon_black_PixelValue = %d\n", enableLastColon_black_PixelValue); posTolerance = SOLARIZE_CHECK_POS_THRESHOLD - ((SOLARIZE_CHECK_NEG_THRESHOLD * aMetricParams->iErrorTolerance.iErrorToleranceR)/100); ALGO_Log_1("posTolerance = %10f\n", posTolerance); if( (enableFirstColon_white_PixelValue <= (disableFirstColon_white_PixelValue - negTolerance) ) && (enableLastColon_black_PixelValue >= (disableLastColon_black_PixelValue + posTolerance) ) ) { return EErrorNone; } else { return EErrorNotValidated; } }
/** * Validation Metric for the Solarize Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricSolarizeEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { #if 1 TUint32 i = 0; TUint32 j = 0; TUint32 index = 0; TUint32 index1 = 0; TInt32 negCheck = 0; TInt32 posCheck = 0; //TUint32 x = 0; //TUint32 y = 0; TReal64 negTolerance = 0; TReal64 posTolerance = 0; TReal64 colonCurrentRImg1 = 0; TReal64 colonCurrentRImg2 = 0; TReal64 colonPreviousImg1 = 0; TReal64 colonPreviousImg2 = 0; TInt32 posDeviationImg1 = 0; TInt32 negDeviationImg1 = 0; TInt32 posDeviationImg2 = 0; TInt32 negDeviationImg2 = 0; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++ ) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); } index1 = startingOffset; index = index1; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabX; i=i+10 ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabY; j++) { colonCurrentRImg1 = colonCurrentRImg1 + aImageEffectDisable->iImageData.iRChannel[index]; index = index + aImageEffectDisable->iImageParams.iImageWidth; } colonCurrentRImg1 = colonCurrentRImg1/aMetricParams->iTestCoordinates.iPixelsToGrabY; if((colonCurrentRImg1 - colonPreviousImg1) > SOLARIZE_THRESHOLD) { posDeviationImg1++; colonPreviousImg1 = colonCurrentRImg1; } if((colonPreviousImg1 - colonCurrentRImg1) > SOLARIZE_THRESHOLD) { negDeviationImg1++; colonPreviousImg1 = colonCurrentRImg1; } colonCurrentRImg1 = 0; index1 = index1 + 10; index = index1; } index1 = startingOffset; index = index1; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabX; i=i+10 ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabY; j++) { colonCurrentRImg2 = colonCurrentRImg2 + aImageEffectEnable->iImageData.iRChannel[index]; index = index + aImageEffectEnable->iImageParams.iImageWidth; } colonCurrentRImg2 = colonCurrentRImg2/aMetricParams->iTestCoordinates.iPixelsToGrabY; if((colonCurrentRImg2 - colonPreviousImg2) > SOLARIZE_THRESHOLD) { posDeviationImg2++; colonPreviousImg2 = colonCurrentRImg2; } if((colonPreviousImg2 - colonCurrentRImg2) > SOLARIZE_THRESHOLD) { negDeviationImg2++; colonPreviousImg2 = colonCurrentRImg2; } colonCurrentRImg2 = 0; index1 = index1 + 10; index = index1; } ALGO_Log_2("posDeviationImg1 = %2d, negDeviationImg1 = %2d\n", posDeviationImg1, negDeviationImg1); ALGO_Log_2("posDeviationImg2 = %2d, negDeviationImg2 = %2d\n", posDeviationImg2, negDeviationImg2); negTolerance = SOLARIZE_CHECK_NEG_THRESHOLD - ((SOLARIZE_CHECK_NEG_THRESHOLD * aMetricParams->iErrorTolerance.iErrorToleranceR)/100); posTolerance = SOLARIZE_CHECK_POS_THRESHOLD - ((SOLARIZE_CHECK_NEG_THRESHOLD * aMetricParams->iErrorTolerance.iErrorToleranceR)/100); negCheck =(negDeviationImg2 - negDeviationImg1); posCheck =(posDeviationImg1 - posDeviationImg2); if((negCheck > negTolerance) && (posCheck > posTolerance)) { return EErrorNone; } else { return EErrorNotValidated; } #else TUint32 index = 0; TUint32 x = 0; TUint32 y = 0; TUint32 InputMean = 0; TUint32 OutputMean = 0; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; TUint32 offset = (aImageEffectDisable->iImageParams.iImageWidth - aMetricParams->iTestCoordinates.iPixelsToGrabX); TUint8 *iR = aImageEffectDisable->iImageData.iRChannel + startingOffset; TUint8 *oR = aImageEffectEnable->iImageData.iRChannel + startingOffset; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++ ) { aImageEffectDisable->iImageData.iRChannel[index] = LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]; aImageEffectEnable->iImageData.iRChannel[index] = LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]; } for(y=0; y < aMetricParams->iTestCoordinates.iPixelsToGrabY - 1; y++) { for (x=0; x < aMetricParams->iTestCoordinates.iPixelsToGrabX - 1; x++) { if(*iR < 128) { *iR = (*iR) * 2; } else { *iR = 512 - ((*iR) * 2); } InputMean = InputMean + *iR; OutputMean = OutputMean + *oR; iR++; oR++; } iR += offset; oR += offset; } InputMean = InputMean/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); OutputMean = OutputMean/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); ALGO_Log_2("LumaInputMean = %10d, LumaOutputMean = %10d\n", InputMean, OutputMean); if( InputMean/OutputMean > 2) { return EErrorNone; } else { return EErrorNotValidated; } //////////////////////////////////////Second Approach////////////////////////////////////// TReal64 R_Avg_Im1 = 0; TReal64 G_Avg_Im1 = 0; TReal64 B_Avg_Im1 = 0; TReal64 Intensity_Im1 = 0; TReal64 R_Avg_Im2 = 0; TReal64 G_Avg_Im2 = 0; TReal64 B_Avg_Im2 = 0; TReal64 Intensity_Im2 = 0; TUint32 index = 0; TUint32 x = 0; TUint32 y = 0; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; TUint32 offset = (aImageEffectDisable->iImageParams.iImageWidth - aMetricParams->iTestCoordinates.iPixelsToGrabX); TUint8 *iR = aImageEffectDisable->iImageData.iRChannel + startingOffset; TUint8 *iG = aImageEffectDisable->iImageData.iGChannel + startingOffset; TUint8 *iB = aImageEffectDisable->iImageData.iBChannel + startingOffset; //TUint8 *oR = aImageEffectEnable->iImageData.iRChannel + startingOffset; //TUint8 *oG = aImageEffectEnable->iImageData.iGChannel + startingOffset; //TUint8 *oB = aImageEffectEnable->iImageData.iBChannel + startingOffset; TUint8 temp = 0; //TUint32 itemp = 0; //TUint32 otemp = 0; for(y=0; y < aMetricParams->iTestCoordinates.iPixelsToGrabY; y++) { for(x=0; x < aMetricParams->iTestCoordinates.iPixelsToGrabX; x++) { if(*iR < 128) { *iR = (*iR) * 2; } else { if(*iR != 128) { *iR = 510 - ((*iR) * 2); } } if(*iG < 128) { *iG = (*iG) * 2; } else { if(*iG != 128) { *iG = 510 - ((*iG) * 2); } } if(*iB < 128) { *iB = (*iB) * 2; } else { if(*iB != 128) { *iB = 510 - ((*iB) * 2); } } /* itemp = ((*iR)+(*iG)+(*iB))/3; if(itemp < 128) { itemp = itemp * 2; } else { itemp = 512 - (itemp * 2); } otemp = ((*oR)+(*oG)+(*oB))/3; Intensity_Im1 = Intensity_Im1 + itemp; Intensity_Im2 = Intensity_Im2 + otemp; */ iR++; iG++; iB++; //oR++; //oG++; //oB++; } iR += offset; iG += offset; iB += offset; //oR += offset; //oG += offset; //oB += offset; } Channel_Average( aImageEffectDisable, &(aMetricParams->iTestCoordinates), &R_Avg_Im1, &G_Avg_Im1, &B_Avg_Im1 ); Channel_Average( aImageEffectEnable, &(aMetricParams->iTestCoordinates), &R_Avg_Im2, &G_Avg_Im2, &B_Avg_Im2 ); //Intensity_Im1 = Intensity_Im1/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); //Intensity_Im2 = Intensity_Im2/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); Intensity_Im1 = (R_Avg_Im1 + G_Avg_Im1 + B_Avg_Im1)/3.255; Intensity_Im2 = (R_Avg_Im2 + G_Avg_Im2 + B_Avg_Im2)/3.255; ALGO_Log_2("Intensity_Im1 = %10f, Intensity_Im2 %10f\n", Intensity_Im1, Intensity_Im2); if( Intensity_Im1 == Intensity_Im2) { return EErrorNone; } else { return EErrorNotValidated; } #endif }
/** * Validation Metric for the Gamma Effect. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricGammaEffect( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TUint32 i = 0; TUint32 j = 0; TUint32 index = 0; TUint32 index1 = 0; TReal64 tolerance = 0; TReal64 colonCurrentRImg1 = 0; TReal64 colonCurrentRImg2 = 0; TReal64 colonPreviousImg1 = 0; TReal64 colonPreviousImg2 = 0; TInt32 posDeviationImg1 = 0; TInt32 negDeviationImg1 = 0; TInt32 posDeviationImg2 = 0; TInt32 negDeviationImg2 = 0; TReal64 prevDeviation = 0; TReal64 currDeviation = 0; TUint32 startingOffset = 0; TAlgoParamGamma *paramGamma = (TAlgoParamGamma*)aMetricParams->iParams; ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); ALGO_Log_2("Gamma Metric : iPrGamma_1 %d, iPrGamma_2 %d\n\n", paramGamma->iPrGamma_1, paramGamma->iPrGamma_2); startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++ ) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); } index1 = startingOffset; index = index1; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabX; i=i+50 ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabY; j++) { colonCurrentRImg1 = colonCurrentRImg1 + aImageEffectDisable->iImageData.iRChannel[index]; index = index + aImageEffectDisable->iImageParams.iImageWidth; } colonCurrentRImg1 = colonCurrentRImg1/aMetricParams->iTestCoordinates.iPixelsToGrabY; if (i == 0) { colonPreviousImg1 = colonCurrentRImg1; } currDeviation = (colonCurrentRImg1 - colonPreviousImg1); ALGO_Log_1("currDeviation = %2f \n", currDeviation); if((currDeviation - prevDeviation) > 0) { posDeviationImg1++; //colonPreviousImg1 = colonCurrentRImg1; } if((prevDeviation - currDeviation) > 0) { negDeviationImg1++; //colonPreviousImg1 = colonCurrentRImg1; } prevDeviation = currDeviation; colonPreviousImg1 = colonCurrentRImg1; colonCurrentRImg1 = 0; index1 = index1 + 50; index = index1; } prevDeviation = 0; currDeviation = 0; index1 = startingOffset; index = index1; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabX; i=i+50 ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabY; j++) { colonCurrentRImg2 = colonCurrentRImg2 + aImageEffectEnable->iImageData.iRChannel[index]; index = index + aImageEffectEnable->iImageParams.iImageWidth; } colonCurrentRImg2 = colonCurrentRImg2/aMetricParams->iTestCoordinates.iPixelsToGrabY; if (i == 0) { colonPreviousImg2 = colonCurrentRImg2; } currDeviation = (colonCurrentRImg2 - colonPreviousImg2); ALGO_Log_1("currDeviation = %2f \n", currDeviation); if((currDeviation - prevDeviation) > 0) { posDeviationImg2++; //colonPreviousImg2 = colonCurrentRImg2; } if((prevDeviation - currDeviation) > 0) { negDeviationImg2++; //colonPreviousImg2 = colonCurrentRImg2; } prevDeviation = currDeviation; colonPreviousImg2 = colonCurrentRImg2; colonCurrentRImg2 = 0; index1 = index1 + 50; index = index1; } ALGO_Log_2("posDeviationImg1 = %2d, negDeviationImg1 = %2d\n", posDeviationImg1, negDeviationImg1); ALGO_Log_2("posDeviationImg2 = %2d, negDeviationImg2 = %2d\n", posDeviationImg2, negDeviationImg2); tolerance = GAMMA_THRESHOLD - aMetricParams->iErrorTolerance.iErrorToleranceR; if(((ABS(negDeviationImg1 - posDeviationImg1)) - (ABS(negDeviationImg2 - posDeviationImg2))) > tolerance) { return EErrorNone; } else { return EErrorNotValidated; } }
/** * Validation Metric for the Gamma Effect basic. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricGammaEffect_basic( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TUint32 index = 0; TReal64 toleranceGamma = 0; TInt32 colorBar_NbColon = 8; TInt32 colorBar_ColonWidth = 0; TUint8 disableColon_1_PixelValue = 0, enableColon_1_PixelValue = 0; TUint8 disableColon_2_PixelValue = 0, enableColon_2_PixelValue = 0; TUint8 disableColon_3_PixelValue = 0, enableColon_3_PixelValue = 0; TUint8 disableColon_4_PixelValue = 0, enableColon_4_PixelValue = 0; TUint8 disableColon_5_PixelValue = 0, enableColon_5_PixelValue = 0; TUint8 disableColon_6_PixelValue = 0, enableColon_6_PixelValue = 0; TUint8 disableColon_7_PixelValue = 0, enableColon_7_PixelValue = 0; TUint8 disableColon_8_PixelValue = 0, enableColon_8_PixelValue = 0; for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++ ) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); } if(aMetricParams->iTestCoordinates.iPixelsToGrabX != aImageEffectDisable->iImageParams.iImageWidth) { ALGO_Log_0("Error, need to work on the whole image (color bar) Width \n"); return EErrorNotValidated; } if(aMetricParams->iTestCoordinates.iPixelsToGrabY != aImageEffectDisable->iImageParams.iImageHeight) { ALGO_Log_0("Error, need to work on the whole image (color bar) Height \n"); return EErrorNotValidated; } if( (aMetricParams->iTestCoordinates.iStartIndexY != 0) || (aMetricParams->iTestCoordinates.iStartIndexX != 0) ) { ALGO_Log_0("Error, need to work on the whole image (color bar) StartIndex\n"); return EErrorNotValidated; } colorBar_ColonWidth = aImageEffectDisable->iImageParams.iImageWidth / colorBar_NbColon; // middle of thh colon and middle of the height disableColon_1_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*1/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_1_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*1/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_2_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*3/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_2_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*3/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_3_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*5/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_3_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*5/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_4_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*7/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_4_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*7/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_5_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*9/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_5_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*9/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_6_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*11/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_6_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*11/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_7_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*13/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_7_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*13/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; disableColon_8_PixelValue = aImageEffectDisable->iImageData.iRChannel[ (colorBar_ColonWidth*15/2) + (aImageEffectDisable->iImageParams.iImageWidth * aImageEffectDisable->iImageParams.iImageHeight / 2)]; enableColon_8_PixelValue = aImageEffectEnable->iImageData.iRChannel[ (colorBar_ColonWidth*15/2) + (aImageEffectEnable->iImageParams.iImageWidth * aImageEffectEnable->iImageParams.iImageHeight / 2)]; ALGO_Log_1("disableColon_1_PixelValue = %d\n", disableColon_1_PixelValue); ALGO_Log_1("enableColon_1_PixelValue = %d\n", enableColon_1_PixelValue); ALGO_Log_1("disableColon_2_PixelValue = %d\n", disableColon_2_PixelValue); ALGO_Log_1("enableColon_2_PixelValue = %d\n", enableColon_2_PixelValue); ALGO_Log_1("disableColon_3_PixelValue = %d\n", disableColon_3_PixelValue); ALGO_Log_1("enableColon_3_PixelValue = %d\n", enableColon_3_PixelValue); ALGO_Log_1("disableColon_4_PixelValue = %d\n", disableColon_4_PixelValue); ALGO_Log_1("enableColon_4_PixelValue = %d\n", enableColon_4_PixelValue); ALGO_Log_1("disableColon_5_PixelValue = %d\n", disableColon_5_PixelValue); ALGO_Log_1("enableColon_5_PixelValue = %d\n", enableColon_5_PixelValue); ALGO_Log_1("disableColon_6_PixelValue = %d\n", disableColon_6_PixelValue); ALGO_Log_1("enableColon_6_PixelValue = %d\n", enableColon_6_PixelValue); ALGO_Log_1("disableColon_7_PixelValue = %d\n", disableColon_7_PixelValue); ALGO_Log_1("enableColon_7_PixelValue = %d\n", enableColon_7_PixelValue); ALGO_Log_1("disableColon_8_PixelValue = %d\n", disableColon_8_PixelValue); ALGO_Log_1("enableColon_8_PixelValue = %d\n", enableColon_8_PixelValue); toleranceGamma = GAMMA_THRESHOLD - ((GAMMA_THRESHOLD * aMetricParams->iErrorTolerance.iErrorToleranceR)/100); ALGO_Log_1("toleranceGamma = %10f\n", toleranceGamma); if( (enableColon_2_PixelValue <= (disableColon_2_PixelValue - toleranceGamma) ) && (enableColon_3_PixelValue <= (disableColon_3_PixelValue - toleranceGamma) ) && (enableColon_4_PixelValue <= (disableColon_4_PixelValue - toleranceGamma) ) && (enableColon_5_PixelValue <= (disableColon_5_PixelValue - toleranceGamma) ) && (enableColon_6_PixelValue <= (disableColon_6_PixelValue - toleranceGamma) ) && (enableColon_7_PixelValue <= (disableColon_7_PixelValue - toleranceGamma) ) ) { return EErrorNone; } else { return EErrorNotValidated; } }
/** * Validation Metric for the ExposureValue. * * @param aImageEffectDisable [TAlgoImage] The image with Effect Disable. * @param aImageEffectEnable [TAlgoImage] The image with Effect Enable. * @param aMetricParams [TAlgoMetricParams]The metric parameters to be applied. * * @return [TAlgoError] EErrorNone if the validation is passed. */ TAlgoError ValidationMetricExposureValue( const TAlgoImage* aImageEffectDisable, const TAlgoImage* aImageEffectEnable, const TAlgoMetricParams* aMetricParams ) { TUint32 i = 0; TUint32 j = 0; TUint32 index = 0; TReal64 Avg_Disable = 0; TReal64 Avg_Enable = 0; TAlgoParamExposureValue *paramExposureValue = (TAlgoParamExposureValue*)aMetricParams->iParams; TUint32 startingOffset = aMetricParams->iTestCoordinates.iStartIndexY * aImageEffectDisable->iImageParams.iImageWidth + aMetricParams->iTestCoordinates.iStartIndexX; TUint32 offset = (aImageEffectDisable->iImageParams.iImageWidth - aMetricParams->iTestCoordinates.iPixelsToGrabX); ALGO_Log_1("entering %s\n", __FUNCTION__); ALGO_Log_3("ToleranceR = %f, ToleranceG = %f, ToleranceB = %f\n", aMetricParams->iErrorTolerance.iErrorToleranceR, aMetricParams->iErrorTolerance.iErrorToleranceG, aMetricParams->iErrorTolerance.iErrorToleranceB); switch(paramExposureValue->iExpoValueType) { case EExpoValue_Metering: { } break; case EExpoValue_EVCompensation: case EExpoValue_Senstivity: { //Getting the luma component for both images in the R Channel. for( index=0; index<(aImageEffectDisable->iImageParams.iImageHeight * aImageEffectDisable->iImageParams.iImageWidth); index++) { aImageEffectDisable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectDisable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectDisable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectDisable->iImageData.iBChannel[index]); aImageEffectEnable->iImageData.iRChannel[index] = (TUint8)(LUMINANCE_R_COEF * aImageEffectEnable->iImageData.iRChannel[index] + LUMINANCE_G_COEF * aImageEffectEnable->iImageData.iGChannel[index] + LUMINANCE_B_COEF * aImageEffectEnable->iImageData.iBChannel[index]); } //Calculating the average of luma components of both images. index = startingOffset; for( i=0; i<aMetricParams->iTestCoordinates.iPixelsToGrabY; i++ ) { for(j=0; j<aMetricParams->iTestCoordinates.iPixelsToGrabX; j++) { Avg_Disable = Avg_Disable + aImageEffectDisable->iImageData.iRChannel[index]; Avg_Enable = Avg_Enable + aImageEffectEnable->iImageData.iRChannel[index]; index++; } index = index + offset; } Avg_Disable = Avg_Disable/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); Avg_Enable = Avg_Enable/(aMetricParams->iTestCoordinates.iPixelsToGrabX * aMetricParams->iTestCoordinates.iPixelsToGrabY); //Ratio Test if(((Avg_Enable/Avg_Disable) > 1.5) && ((Avg_Enable/Avg_Disable) < 2.5)) { ALGO_Log_0("ExposureValue Metric : PASSED in Ratio Test \n\n"); ALGO_Log_1("ExposureValue Metric : Avg_Enable/Avg_Disable = %f\n\n", (Avg_Enable/Avg_Disable)); } else { ALGO_Log_0("ExposureValue Metric : FAILED in Ratio Test \n\n"); ALGO_Log_1("ExposureValue Metric : Avg_Enable/Avg_Disable = %f\n\n", (Avg_Enable/Avg_Disable)); } ALGO_Log_2("ExposureValue Metric : Avg_Disable = %.3f, Avg_Enable = %.3f\n\n", Avg_Disable, Avg_Enable); ALGO_Log_2("ExposureValue Metric : ExposureValue_Disable = %f, ExposureValue_Enable = %f\n\n", paramExposureValue->iExposureValue_Disable, paramExposureValue->iExposureValue_Enable); if(((Avg_Disable < Avg_Enable) && (paramExposureValue->iExposureValue_Disable < paramExposureValue->iExposureValue_Enable )) || ((Avg_Disable > Avg_Enable) && (paramExposureValue->iExposureValue_Disable > paramExposureValue->iExposureValue_Enable ))) { return EErrorNone; } else { return EErrorNotValidated; } } //break; //set in comment to avoid warnings // break not needed because of returns above // when changing above code, break might be required case EExpoValue_ApertureFNumber: { } break; case EExpoValue_ApertureAuto: { } break; case EExpoValue_ShutterSpeedMsec: { } break; case EExpoValue_ShutterSpeedAuto: { } break; case EExpoValue_SenstivityAuto: { } break; default: { return EErrorNotSupported; } } ALGO_Log_2("ExposureValue Metric : iExposureValue_Disable %d, iExposureValue_Enable %d\n\n", paramExposureValue->iExposureValue_Disable, paramExposureValue->iExposureValue_Enable); return EErrorNotValidated; }