user1081326
user1081326

Reputation: 425

Applying pixel to a mask

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?

Upvotes: 0

Views: 154

Answers (1)

CookieOfFortune
CookieOfFortune

Reputation: 13984

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.

Upvotes: 1

Related Questions