src/ccstruct/otsuthr.cpp
void HistogramRect(Image src_pix, int channel, int left, int top, int width, int height,
                   int *histogram) {
  int num_channels = pixGetDepth(src_pix) / 8;
  channel = ClipToRange(channel, 0, num_channels - 1);
  int bottom = top + height;
  memset(histogram, 0, sizeof(*histogram) * kHistogramSize);
  int src_wpl = pixGetWpl(src_pix);
  l_uint32 *srcdata = pixGetData(src_pix);
  for (int y = top; y < bottom; ++y) {
    const l_uint32 *linedata = srcdata + y * src_wpl;
    for (int x = 0; x < width; ++x) {
      int pixel = GET_DATA_BYTE(linedata, (x + left) * num_channels + channel);
      ++histogram[pixel];
    }
  }
}
// Computes the histogram for the given image rectangle, and the given
// single channel. Each channel is always one byte per pixel.
// Histogram is always a kHistogramSize(256) element array to count
// occurrences of each pixel value.
Computes the histogram for the given image rectangle, and the given
single channel. Each channel is always one byte per pixel.
Histogram is always a kHistogramSize(256) element array to count
occurrences of each pixel value.
Computes the histogram for the given image rectangle and the given single channel . Each channel is always one byte per pixel . Histogram is always a kHistogramSize ( 256 ) element array to count occurrences of each pixel value .
void HistogramRect(Image src_pix, int channel, int left, int top, int width, int height,
                   int *histogram) {
  int num_channels = pixGetDepth(src_pix) / 8;
  channel = ClipToRange(channel, 0, num_channels - 1);
  int bottom = top + height;
  memset(histogram, 0, sizeof(*histogram) * kHistogramSize);
  int src_wpl = pixGetWpl(src_pix);
  l_uint32 *srcdata = pixGetData(src_pix);
  for (int y = top; y < bottom; ++y) {
    const l_uint32 *linedata = srcdata + y * src_wpl;
    for (int x = 0; x < width; ++x) {
      int pixel = GET_DATA_BYTE(linedata, (x + left) * num_channels + channel);
      ++histogram[pixel];
    }
  }
}
void HistogramRect ( Image src_pix , int channel , int left , int top , int width , int height , int * histogram ) { int num_channels = pixGetDepth ( src_pix ) / 8 ; channel = ClipToRange ( channel , 0 , num_channels - 1 ) ; int bottom = top + height ; memset ( histogram , 0 , sizeof ( * histogram ) * kHistogramSize ) ; int src_wpl = pixGetWpl ( src_pix ) ; l_uint32 * srcdata = pixGetData ( src_pix ) ; for ( int y = top ; y < bottom ; ++ y ) { const l_uint32 * linedata = srcdata + y * src_wpl ; for ( int x = 0 ; x < width ; ++ x ) { int pixel = GET_DATA_BYTE ( linedata , ( x + left ) * num_channels + channel ) ; ++ histogram [ pixel ] ; } } }
Computes the histogram for the given image rectangle, and the given
single channel.
Computes the histogram for the given image rectangle and the given single channel .