MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / processInputData

Method processInputData

IPL/src/processes/IPLArithmeticOperations.cpp:66–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66bool IPLArithmeticOperations::processInputData(IPLData* data, int imageIndex, bool)
67{
68 IPLImage* image = data->toImage();
69
70 // save the first image
71 if(imageIndex == 0)
72 {
73 delete _inputA;
74 _inputA = new IPLImage(*image);
75 }
76
77 // save the second image
78 if(imageIndex == 1)
79 {
80 delete _inputB;
81 _inputB = new IPLImage(*image);
82 }
83
84 // only continue if we have 2 valid inputs
85 if(!(_inputA && _inputB))
86 {
87 return false;
88 }
89
90 // delete previous result
91 delete _result;
92 _result = NULL;
93
94 // the result will be the max size of both inputs
95 int width = std::max(_inputA->width(), _inputB->width());
96 int height = std::max(_inputA->height(), _inputB->height());
97
98 // copy constructor doesnt work:
99 // _result = new IPLImage(*image);
100
101 // get properties
102 _operation = getProcessPropertyInt("operation");
103
104 int maxNrOfPlanes = std::max( _inputA->getNumberOfPlanes(), _inputB->getNumberOfPlanes());
105 int progress = 0;
106 int maxProgress = maxNrOfPlanes*height;
107
108 IPLDataType type = IPL_IMAGE_COLOR;
109 if(maxNrOfPlanes == 1)
110 type = IPL_IMAGE_GRAYSCALE;
111
112 // create result
113 _result = new IPLImage(type, width, height);
114
115 #pragma omp parallel for
116 for( int planeNr=0; planeNr < maxNrOfPlanes; planeNr++ )
117 {
118 // prevent reading unavailable planes
119 IPLImagePlane* planeA = _inputA->plane(std::min(planeNr, _inputA->getNumberOfPlanes()-1));
120 IPLImagePlane* planeB = _inputB->plane(std::min(planeNr, _inputB->getNumberOfPlanes()-1));
121 IPLImagePlane* newplane = _result->plane(planeNr);
122
123 for(int y=0; y<height; y++)

Callers

nothing calls this directly

Calls 6

toImageMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
planeMethod · 0.80
maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected