| 27 | } |
| 28 | |
| 29 | bool %CLASSNAME%::processInputData(IPLImage *image, int, bool useOpenCV) |
| 30 | { |
| 31 | // delete previous result |
| 32 | delete _result; |
| 33 | _result = NULL; |
| 34 | |
| 35 | int width = image->width(); |
| 36 | int height = image->height(); |
| 37 | if( image->type() == IPL_IMAGE_GRAYSCALE ) |
| 38 | _result = new IPLImage( IPL_IMAGE_BW, width, height ); |
| 39 | else |
| 40 | _result = new IPLImage( image->type(), width, height ); |
| 41 | |
| 42 | // get properties |
| 43 | float threshold = getProcessPropertyDouble("threshold"); |
| 44 | |
| 45 | int progress = 0; |
| 46 | int maxProgress = image->height() * image->getNumberOfPlanes(); |
| 47 | int nrOfPlanes = image->getNumberOfPlanes(); |
| 48 | |
| 49 | #pragma omp parallel for |
| 50 | for( int planeNr=0; planeNr < nrOfPlanes; planeNr++ ) |
| 51 | { |
| 52 | IPLImagePlane* plane = image->plane( planeNr ); |
| 53 | IPLImagePlane* newplane = _result->plane( planeNr ); |
| 54 | for(int y=0; y<height; y++) |
| 55 | { |
| 56 | // progress |
| 57 | notifyProgressEventHandler(100*progress++/maxProgress); |
| 58 | for(int x=0; x<width; x++) |
| 59 | { |
| 60 | newplane->p(x,y) = (plane->p(x,y) < threshold) ? 0.0f : 1.0f; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | IPLData *%CLASSNAME%::getResultData(int) |
| 68 | { |