| 44 | } |
| 45 | |
| 46 | bool IPLEnhanceMode::processInputData(IPLData* data, int, bool) |
| 47 | { |
| 48 | IPLImage* image = data->toImage(); |
| 49 | |
| 50 | // delete previous result |
| 51 | delete _result; |
| 52 | _result = NULL; |
| 53 | |
| 54 | int width = image->width(); |
| 55 | int height = image->height(); |
| 56 | _result = new IPLImage( image->type(), width, height ); |
| 57 | |
| 58 | // get properties |
| 59 | float window = getProcessPropertyInt("window"); |
| 60 | |
| 61 | int progress = 0; |
| 62 | int maxProgress = image->height() * image->getNumberOfPlanes(); |
| 63 | int nrOfPlanes = image->getNumberOfPlanes(); |
| 64 | |
| 65 | int w2 = window/2; |
| 66 | int area = window * window; |
| 67 | |
| 68 | #pragma omp parallel for |
| 69 | for( int planeNr=0; planeNr < nrOfPlanes; planeNr++ ) |
| 70 | { |
| 71 | IPLImagePlane* plane = image->plane( planeNr ); |
| 72 | IPLImagePlane* newplane = _result->plane( planeNr ); |
| 73 | |
| 74 | |
| 75 | int H[256], W[256]; |
| 76 | for( int z=0; z<256; z++ ) |
| 77 | H[z] = 0; |
| 78 | |
| 79 | for(int y=w2; y<height-w2; y++) |
| 80 | { |
| 81 | // progress |
| 82 | notifyProgressEventHandler(100*progress++/maxProgress); |
| 83 | for(int x=w2; x<width-w2; x++) |
| 84 | { |
| 85 | // operator |
| 86 | for( int ky=-w2; ky <= w2; ky++) |
| 87 | { |
| 88 | for( int kx=-w2; kx <= w2; kx++) |
| 89 | { |
| 90 | int index = (int) (plane->p(x+kx, y+ky) * FACTOR_TO_UCHAR); |
| 91 | H[index]++; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // bucketsort |
| 96 | int z = 0; |
| 97 | for( int u=0; u<256; u++ ) |
| 98 | { |
| 99 | if(H[u] > 0) |
| 100 | { |
| 101 | while( H[u] > 0) |
| 102 | { |
| 103 | W[z++] = u; |