| 86 | } |
| 87 | |
| 88 | bool IPLBlendImages::processInputData(IPLData* data , int imageIndex, bool) |
| 89 | { |
| 90 | IPLImage* image = data->toImage(); |
| 91 | |
| 92 | // save the first image |
| 93 | if(imageIndex == 0) |
| 94 | { |
| 95 | delete _inputA; |
| 96 | _inputA = new IPLImage(*image); |
| 97 | } |
| 98 | |
| 99 | // save the second image |
| 100 | if(imageIndex == 1) |
| 101 | { |
| 102 | delete _inputB; |
| 103 | _inputB = new IPLImage(*image); |
| 104 | } |
| 105 | |
| 106 | // only continue if we have 2 valid inputs |
| 107 | if(!(_inputA && _inputB)) |
| 108 | { |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | // delete previous result |
| 113 | delete _result; |
| 114 | _result = NULL; |
| 115 | |
| 116 | // the result will be the max size of both inputs |
| 117 | int width = std::max(_inputA->width(), _inputB->width()); |
| 118 | int height = std::max(_inputA->height(), _inputB->height()); |
| 119 | |
| 120 | // copy constructor doesnt work: |
| 121 | // _result = new IPLImage(*image); |
| 122 | |
| 123 | // get properties |
| 124 | _operation = getProcessPropertyInt("operation"); |
| 125 | _factorA = getProcessPropertyDouble("factorA"); |
| 126 | _factorB = getProcessPropertyDouble("factorB"); |
| 127 | |
| 128 | int maxNrOfPlanes = std::max( _inputA->getNumberOfPlanes(), _inputB->getNumberOfPlanes()); |
| 129 | int progress = 0; |
| 130 | int maxProgress = maxNrOfPlanes*height; |
| 131 | |
| 132 | IPLDataType type = IPL_IMAGE_COLOR; |
| 133 | if(maxNrOfPlanes == 1) |
| 134 | type = IPL_IMAGE_GRAYSCALE; |
| 135 | |
| 136 | // create result |
| 137 | _result = new IPLImage(type, width, height); |
| 138 | |
| 139 | #pragma omp parallel for |
| 140 | for( int planeNr=0; planeNr < maxNrOfPlanes; planeNr++ ) |
| 141 | { |
| 142 | // prevent reading unavailable planes |
| 143 | IPLImagePlane* planeA = _inputA->plane(std::min(planeNr, _inputA->getNumberOfPlanes()-1)); |
| 144 | IPLImagePlane* planeB = _inputB->plane(std::min(planeNr, _inputB->getNumberOfPlanes()-1)); |
| 145 | IPLImagePlane* newplane = _result->plane(planeNr); |