static inline void add_val (DespeckleHistogram *hist, const guchar *src, gint width, gint bpp, gint x, gint y) { const gint pos = (x + (y * width)) * bpp; const gint value = pixel_luminance (src + pos, bpp); if (value > black_level && value < white_level) { histogram_add (hist, value, src + pos); histrest++; } else { if (value <= black_level) hist0++; if (value >= white_level) hist255++; } }
int dogfs_read(const char *path, char *buf, size_t len, off_t off, struct fuse_file_info *fi) { #ifdef SIZE_STATS histogram_add(&reads, len); #endif file_t *f = get_file(fi); int r = file_flush(f); if (r < 0) return r; return run_with_connection(inode_read, f->i, buf, len, off, true); }
int DjVuPalette::compute_pixmap_palette(const GPixmap &pm, int ncolors, int minboxsize) { // Prepare histogram histogram_clear(); { // extra nesting for windows for (int j=0; j<(int)pm.rows(); j++) { const GPixel *p = pm[j]; for (int i=0; i<(int)pm.columns(); i++) histogram_add(p[i], 1); } } // Compute palette return compute_palette(ncolors, minboxsize); }