Skip to content

Instantly share code, notes, and snippets.

View johnnyferreiradev's full-sized avatar

Johnny Ferreira johnnyferreiradev

View GitHub Profile
@johnnyferreiradev
johnnyferreiradev / operadorPrewitt.cpp
Created March 16, 2019 14:43
Operadores de Prewitt para processamento digital de imagens (Filtro 3x3)
Mat operadoresPrewitt(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) + img.at<uchar>(i,j+1) + img.at<uchar>(i+1,j+1)) -
(img.at<uchar>(i-1, j-1) + img.at<uchar>(i, j-1) + img.at<uchar>(i+1, j-1));
@johnnyferreiradev
johnnyferreiradev / operadorRobert.cpp
Last active March 16, 2019 14:09
Operadores cruzados de Robert para processamento digital de imagens (Filtro 3x3)
Mat operadorRobert(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,j) - img.at<uchar>(i+1,j+1);
gy = img.at<uchar>(i+1,j) - img.at<uchar>(i,j+1);
imgResultante.at<uchar>(i,j) = sqrt(pow(gx,2) + pow(gy,2));
@johnnyferreiradev
johnnyferreiradev / convolucaoGenerica.cpp
Created March 16, 2019 12:46
Função para realizar uma convolução de forma genérica em uma imagem (OpenCV)
#include <opencv2/opencv.hpp>
Mat convoluirGenerica(Mat& img, float **masc, int M, int N){
float output=0;
Mat resp = img.clone();
int m=(M-1)/2;
int n=(N-1)/2;
for (int x=0; x<img.rows;x++){