MCPcopy Create free account
hub / github.com/davisking/dlib / partition_pixels_float

Function partition_pixels_float

dlib/image_transforms/thresholding.h:142–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140 typename ...T
141 >
142 void partition_pixels_float (
143 const image_type& img_,
144 typename pixel_traits<typename image_traits<image_type>::pixel_type>::basic_pixel_type& pix_thresh,
145 T&& ...more_thresholds
146 )
147 {
148 /*
149 This is a version of partition_pixels() that doesn't use the histogram to
150 perform a radix sort but rather uses std::sort() as the first processing
151 step. It is therefor useful in cases where the range of possible pixels is
152 too large for the faster histogram version.
153 */
154
155 COMPILE_TIME_ASSERT( pixel_traits<typename image_traits<image_type>::pixel_type>::has_alpha == false );
156
157 typedef typename pixel_traits<typename image_traits<image_type>::pixel_type>::basic_pixel_type basic_pixel_type;
158
159 const_image_view<image_type> img(img_);
160
161 std::vector<basic_pixel_type> sorted;
162 sorted.reserve(img.size());
163
164 for (long r = 0; r < img.nr(); ++r)
165 {
166 for (long c = 0; c < img.nc(); ++c)
167 sorted.emplace_back(get_pixel_intensity(img[r][c]));
168 }
169 std::sort(sorted.begin(), sorted.end());
170
171 std::vector<double> cumsum;
172 cumsum.reserve(sorted.size()+1);
173
174 // create integral array
175 cumsum.emplace_back(0);
176 for (auto& v : sorted)
177 cumsum.emplace_back(cumsum.back()+v);
178
179
180
181 recursive_partition_pixels_float(0, img.size(), cumsum, sorted, pix_thresh, more_thresholds...);
182
183 }
184
185
186 template <typename image_type>

Callers 2

test_partition_pixelsFunction · 0.85
partition_pixelsFunction · 0.85

Calls 10

get_pixel_intensityFunction · 0.85
emplace_backMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
backMethod · 0.45

Tested by 1

test_partition_pixelsFunction · 0.68