| 21 | typename MM |
| 22 | > |
| 23 | void get_histogram ( |
| 24 | const in_image_type& in_img_, |
| 25 | matrix<unsigned long,R,C,MM>& hist, |
| 26 | size_t hist_size |
| 27 | ) |
| 28 | { |
| 29 | typedef typename image_traits<in_image_type>::pixel_type pixel_type; |
| 30 | COMPILE_TIME_ASSERT( pixel_traits<pixel_type>::is_unsigned == true ); |
| 31 | |
| 32 | // make sure hist is the right size |
| 33 | if (R == 1) |
| 34 | hist.set_size(1,hist_size); |
| 35 | else |
| 36 | hist.set_size(hist_size,1); |
| 37 | |
| 38 | |
| 39 | set_all_elements(hist,0); |
| 40 | |
| 41 | const_image_view<in_image_type> in_img(in_img_); |
| 42 | // compute the histogram |
| 43 | for (long r = 0; r < in_img.nr(); ++r) |
| 44 | { |
| 45 | for (long c = 0; c < in_img.nc(); ++c) |
| 46 | { |
| 47 | auto p = get_pixel_intensity(in_img[r][c]); |
| 48 | if (p < hist_size) |
| 49 | ++hist(p); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | // ---------------------------------------------------------------------------------------- |
| 55 | |