In your kernel, you're not setting the pixel in image b
to anything if the pixel in image a
is white. You should change it to something like the following:
b[y * sizex + x] = (a[y * sizex + x] == 255) ? 0 : a[y * sizex + x];
Which will set the pixel in image b to zero if the pixel in image a is white, and copy the pixel unchanged otherwise. Also consider doing this kind of manipulation in-place, such that only one buffer is needed.