Created
March 16, 2019 14:44
-
-
Save johnnyferreiradev/65c2c0d59fef1bc2190649f9eeb55d7a to your computer and use it in GitHub Desktop.
Operadores de Sabel para processamento digital de imagens (Filtro 3x3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mat operadoresSabel(Mat img){ | |
Mat imgResultante = img.clone(); | |
int gx,gy; | |
for(int i=0; i< img.rows; i++){ | |
for(int j=0; j < img.cols; j++){ | |
gx = (img.at<uchar>(i+1,j-1) + 2*(img.at<uchar>(i+1,j)) + img.at<uchar>(i+1,j+1)) - | |
(img.at<uchar>(i-1, j-1) + 2*(img.at<uchar>(i-1, j)) + img.at<uchar>(i-1, j+1)); | |
gy = (img.at<uchar>(i-1,j+1) + 2*(img.at<uchar>(i,j+1)) + img.at<uchar>(i+1,j+1)) - | |
(img.at<uchar>(i-1, j-1) + 2*(img.at<uchar>(i, j-1)) + img.at<uchar>(i+1, j-1)); | |
imgResultante.at<uchar>(i,j) = sqrt(pow(gx, 2) + pow(gy, 2)); | |
} | |
} | |
return imgResultante; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment