Question

Im currently adding different features to a very simple digital image processing program. It is coded using the unsafe methods. This program only works with greyscale images.

My question is how do i apply masks to pixels?

Was it helpful?

Solution

Just multiply pix_vals by the mask and sum. So just add:

p[y * stride + x] = pix_val[0] * Gx[0] + ... + pix_val[8] * Gx[8];

EDIT: Watch out for the corner cases though, you should really change your offsets to [-1, 0, 1] instead of [0, 1, 2] and handle the boundary conditions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top