//--------------------------------------------------------- bool COpenCV_FFT::On_Execute(void) { CSG_Grid *pInput, *pReal, *pImag; pInput = Parameters("INPUT") ->asGrid(); pReal = Parameters("REAL") ->asGrid(); pImag = Parameters("IMAG") ->asGrid(); //----------------------------------------------------- IplImage *cv_pInput = Get_CVImage(pInput, SG_DATATYPE_Float); IplImage *cv_pReal = NULL;// Get_CVImage(Get_NX(), Get_NY(), SG_DATATYPE_Float); IplImage *cv_pImag = NULL;// Get_CVImage(Get_NX(), Get_NY(), SG_DATATYPE_Float); //----------------------------------------------------- DFT(cv_pInput, &cv_pReal, &cv_pImag); //----------------------------------------------------- Copy_CVImage_To_Grid(pReal, cv_pReal, false); Copy_CVImage_To_Grid(pImag, cv_pImag, false); cvReleaseImage(&cv_pInput); cvReleaseImage(&cv_pReal); cvReleaseImage(&cv_pImag); pReal->Set_Name(CSG_String::Format(SG_T("%s [DFT, %s]"), pInput->Get_Name(), _TL("Real"))); pImag->Set_Name(CSG_String::Format(SG_T("%s [DFT, %s]"), pInput->Get_Name(), _TL("Imaginary"))); return( true ); }
//--------------------------------------------------------- bool COpenCV_Morphology::On_Execute(void) { int Type, Shape, Radius, Iterations; CSG_Grid *pInput, *pOutput; pInput = Parameters("INPUT") ->asGrid(); pOutput = Parameters("OUTPUT") ->asGrid(); Type = Parameters("TYPE") ->asInt(); Shape = Parameters("SHAPE") ->asInt(); Radius = Parameters("RADIUS") ->asInt(); Iterations = Parameters("ITERATIONS") ->asInt(); //----------------------------------------------------- switch( Shape ) { default: case 0: Shape = CV_SHAPE_ELLIPSE; break; case 1: Shape = CV_SHAPE_RECT; break; case 2: Shape = CV_SHAPE_CROSS; break; } //----------------------------------------------------- IplImage *cv_pInput = Get_CVImage(pInput); IplImage *cv_pOutput = Get_CVImage(Get_NX(), Get_NY(), pInput->Get_Type()); IplImage *cv_pTmp = NULL; //----------------------------------------------------- IplConvKernel *cv_pElement = cvCreateStructuringElementEx(Radius * 2 + 1, Radius * 2 + 1, Radius, Radius, Shape, 0); switch( Type ) { case 0: // dilation cvDilate (cv_pInput, cv_pOutput, cv_pElement, Iterations); break; case 1: // erosion cvErode (cv_pInput, cv_pOutput, cv_pElement, Iterations); break; case 2: // opening cvMorphologyEx (cv_pInput, cv_pOutput, cv_pTmp, cv_pElement, CV_MOP_OPEN , Iterations ); break; case 3: // closing cvMorphologyEx (cv_pInput, cv_pOutput, cv_pTmp, cv_pElement, CV_MOP_CLOSE , Iterations ); break; case 4: // morpological gradient cvMorphologyEx (cv_pInput, cv_pOutput, cv_pTmp = Get_CVImage(Get_NX(), Get_NY(), pInput->Get_Type()), cv_pElement, CV_MOP_GRADIENT, Iterations ); break; case 5: // top hat cvMorphologyEx (cv_pInput, cv_pOutput, cv_pTmp = Get_CVImage(Get_NX(), Get_NY(), pInput->Get_Type()), cv_pElement, CV_MOP_TOPHAT , Iterations ); break; case 6: // black hat cvMorphologyEx (cv_pInput, cv_pOutput, cv_pTmp = Get_CVImage(Get_NX(), Get_NY(), pInput->Get_Type()), cv_pElement, CV_MOP_BLACKHAT, Iterations ); break; } cvReleaseStructuringElement(&cv_pElement); //----------------------------------------------------- Copy_CVImage_To_Grid(pOutput, cv_pOutput); cvReleaseImage(&cv_pInput); cvReleaseImage(&cv_pOutput); if( cv_pTmp ) { cvReleaseImage(&cv_pTmp); } pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), Get_Name().c_str())); return( true ); }