Unsharp masking

Yes,exactly…to have the values in some range.
a) (k * (float)(src.at(y, x) - res.at(y, x))) can be negative,
b) src.at(y,x) + (k * (float)(src.at(y, x) - res.at(y, x))) can be greater than 255 and can be smaller than 0.
Performing a saturated add

I posted here earlier but I wouldnt post the whole code unfortunately,buts its there on stackoverflow