Code:
rgblab = new long[16777216];
labrgb = new long[16777216];
and no delete[] for both arrays, basic memory leak..
use smart pointers if you want some kind of automatic GC for C++ like in Java or C#
and both arrays do not feature a runtime determined length, simply make them static if worrying about blowing the stack up
Code:
static int32_t rgblab[16777216];
static int32_t labrgb[16777216];