Skip to content

Commit 173d25c

Browse files
committed
Merge pull request #2978 from berak:fix_fuzzy_memleak
2 parents 4613c51 + dfd321d commit 173d25c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

modules/fuzzy/src/fuzzy_F0_math.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ void ft::FT02D_FL_process(InputArray matrix, const int radius, OutputArray outpu
122122
int output_height = matrix.rows();
123123
int output_width = matrix.cols();
124124

125-
uchar *img_r = new uchar[output_height * output_width];
126-
uchar *img_g = new uchar[output_height * output_width];
127-
uchar *img_b = new uchar[output_height * output_width];
125+
Mat compR(output_height, output_width, CV_8UC1);
126+
Mat compG(output_height, output_width, CV_8UC1);
127+
Mat compB(output_height, output_width, CV_8UC1);
128+
129+
uchar *img_r = compR.ptr();
130+
uchar *img_g = compG.ptr();
131+
uchar *img_b = compB.ptr();
128132

129133
for (int y = 0; y < output_height; y++)
130134
{
@@ -158,10 +162,6 @@ void ft::FT02D_FL_process(InputArray matrix, const int radius, OutputArray outpu
158162
}
159163
}
160164

161-
Mat compR(output_height, output_width, CV_8UC1, img_r);
162-
Mat compG(output_height, output_width, CV_8UC1, img_g);
163-
Mat compB(output_height, output_width, CV_8UC1, img_b);
164-
165165
std::vector<Mat> oComp;
166166

167167
oComp.push_back(compB);
@@ -250,9 +250,13 @@ void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray
250250
int output_height = matrix.rows();
251251
int output_width = matrix.cols();
252252

253-
float *img_r = new float[output_height * output_width];
254-
float *img_g = new float[output_height * output_width];
255-
float *img_b = new float[output_height * output_width];
253+
Mat compR(output_height, output_width, CV_32FC1);
254+
Mat compG(output_height, output_width, CV_32FC1);
255+
Mat compB(output_height, output_width, CV_32FC1);
256+
257+
float *img_r = compR.ptr<float>();
258+
float *img_g = compG.ptr<float>();
259+
float *img_b = compB.ptr<float>();
256260

257261
for (int y = 0; y < output_height; y++)
258262
{
@@ -286,10 +290,6 @@ void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray
286290
}
287291
}
288292

289-
Mat compR(output_height, output_width, CV_32FC1, img_r);
290-
Mat compG(output_height, output_width, CV_32FC1, img_g);
291-
Mat compB(output_height, output_width, CV_32FC1, img_b);
292-
293293
std::vector<Mat> oComp;
294294

295295
oComp.push_back(compB);

0 commit comments

Comments
 (0)