| 55 | } |
| 56 | |
| 57 | bool IPLMergePlanes::processInputData(IPLData* data, int imageIndex, bool) |
| 58 | { |
| 59 | IPLImage* image = data->toImage(); |
| 60 | |
| 61 | // save the inputs |
| 62 | if(imageIndex == 0) |
| 63 | { |
| 64 | delete _inputA; |
| 65 | _inputA = new IPLImage(*image); |
| 66 | } |
| 67 | if(imageIndex == 1) |
| 68 | { |
| 69 | delete _inputB; |
| 70 | _inputB = new IPLImage(*image); |
| 71 | } |
| 72 | if(imageIndex == 2) |
| 73 | { |
| 74 | delete _inputC; |
| 75 | _inputC = new IPLImage(*image); |
| 76 | } |
| 77 | |
| 78 | // only continue if we have 3 valid inputs |
| 79 | if(!(_inputA && _inputB && _inputC)) |
| 80 | { |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | // get properties |
| 85 | int inputType = getProcessPropertyInt("input_type"); |
| 86 | |
| 87 | int width = std::max(std::max(_inputA->width(), _inputB->width()), _inputC->width()); |
| 88 | int height = std::max(std::max(_inputA->height(), _inputB->height()), _inputC->height()); |
| 89 | |
| 90 | delete _result; |
| 91 | _result = new IPLImage(IPL_IMAGE_COLOR, width, height); |
| 92 | |
| 93 | int progress = 0; |
| 94 | int maxProgress = image->height() * _result->getNumberOfPlanes(); |
| 95 | |
| 96 | // copy data |
| 97 | for(int y=0; y<height; y++) |
| 98 | { |
| 99 | // progress |
| 100 | notifyProgressEventHandler(100*progress++/maxProgress); |
| 101 | |
| 102 | for(int x=0; x<width; x++) |
| 103 | { |
| 104 | // RGB |
| 105 | float r = _inputA->plane(0)->cp(x, y); |
| 106 | float g = _inputB->plane(0)->cp(x, y); |
| 107 | float b = _inputC->plane(0)->cp(x, y); |
| 108 | |
| 109 | // HSV |
| 110 | if(inputType == 1) |
| 111 | { |
| 112 | float rgb[3]; |
| 113 | IPLColor::hsvToRgb(r, g, b, rgb); |
| 114 | r = rgb[0]; |