Uncategorized

Hamming distance calculation

Posted on

This is a small snippet of how to calculate hamming distance in cpp with small bit of assembly for doing a population count. Code typedef unsigned long long hash_t;   #include <iostream> #include <bitset>   int popcount64(const hash_t& val) noexcept { int ret; __asm__ ("popcnt %1, %1" : "=r" (ret) : "0" (val)); return ret; […]

Uncategorized

Histogram Comparison for Image Analysis

Posted on

DRAFT This is the first article in the series on Image Comparison using Local Binary Patterns. Complete code is on github lbp-matcher We will start off by looking at different methods of comparing histograms. Histogram Intersection Log Likehood Chi Squared Kullback Leibler Divergence All our operations will be performed on 8bpp(bits per pixel) images anything […]

cpp

Dump leptonica pix data to console

Posted on

Small utility for dumping Leptonica Pix data to the screen. void dump(PIX* pix) { int_t w = pix->w; int_t h = pix->h;   int_t wpl = pixGetWpl(pix); l_uint32* data = pixGetData(pix); l_uint32* line;   printf("\n"); printf("Depth : %d \n", pix->d);   for (int_t y = 0; y < h; ++y) { printf("%04d : ", y); […]