Skip to content

Commit 8bfaf84

Browse files
committed
move new&delete histogramAllChannels inside the #ifdef USE_OPENCL; fixes #248
1 parent 4d4bfb5 commit 8bfaf84

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ccstruct/otsuthr.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ int OtsuThreshold(Pix* src_pix, int left, int top, int width, int height,
4848
double best_hi_dist = 0.0;
4949
*thresholds = new int[num_channels];
5050
*hi_values = new int[num_channels];
51-
// all of channel 0 then all of channel 1...
52-
int *histogramAllChannels = new int[kHistogramSize * num_channels];
5351

5452
// only use opencl if compiled w/ OpenCL and selected device is opencl
5553
#ifdef USE_OPENCL
54+
// all of channel 0 then all of channel 1...
55+
int *histogramAllChannels = new int[kHistogramSize * num_channels];
56+
5657
// Calculate Histogram on GPU
5758
OpenclDevice od;
5859
if (od.selectedDeviceIsOpenCL() &&
@@ -139,8 +140,9 @@ int OtsuThreshold(Pix* src_pix, int left, int top, int width, int height,
139140
}
140141
#ifdef USE_OPENCL
141142
}
142-
#endif // USE_OPENCL
143143
delete[] histogramAllChannels;
144+
#endif // USE_OPENCL
145+
144146

145147
if (!any_good_hivalue) {
146148
// Use the best of the ones that were not good enough.

0 commit comments

Comments
 (0)