I am new to opencv and I am trying to perform unsharp masking ,however there some errors that that the resulting pixels can be <0 or >255 so they need to be scaled down.
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