cv::Vec3b determinePixelValueByConv(cv::Mat& neigbourhood){
int coeffs[3][3] = { { -1, -1, -1 }, { -1, 8, -1 }, { -1, -1, -1 } };
cv::Mat_<cv::Vec3b> _neigbourhood = neigbourhood;
cv::Vec3b centralPixel = _neigbourhood(1, 1);
cv::Vec3b outputPixel = cv::Vec3b();
for (int k = 0; k < 3; k++){
int product_sum = 0;
for (int i = 0; i < _neigbourhood.rows; ++i){
for (int j = 0; j < _neigbourhood.cols; ++j){
product_sum += (_neigbourhood(i, j)[k] * coeffs[i][j]);
}
}
outputPixel[k] = cutToRange((int)(product_sum));
}
return outputPixel;
}
cv::Mat edgingConvolution(cv::Mat& I){
cv::Mat imageCopy = shallowCopy(I);
cv::Mat_<cv::Vec3b> _I = I;
for (int i = 1; i < I.rows - 1; i++){
for (int j = 1; j < I.cols - 1; j++){
cv::Mat neigbourhood = imageCopy(cv::Rect(j - 1, i - 1, 3, 3));
cv::Vec3b outputPixel = determinePixelValueByConv(neigbourhood);
_I(i, j)[0] = outputPixel[0];
_I(i, j)[1] = outputPixel[1];
_I(i, j)[2] = outputPixel[2];
}
}
I = _I;
return I;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}