Académique Documents
Professionnel Documents
Culture Documents
TEMA:
FILTROS INDIVIDUALES POR COMPONENTE (RGB) Y EN COLOR
AUTOR:
FERNANDO RECALDE
NIVEL: 9° MECATRÓNICA
LATACUNGA
2019
CÓDIGO
#include <iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
int main()
{
VideoCapture cap(0);
Mat img, filtrorojo;
vector<Mat> RGBChannels(3);
Mat rgb_union[3];
Mat filtro_final;
while (true) {
cap >> img;
// img=imread("D:\\ARCHIVOS\\rgb.jpg");
split(img, RGBChannels);
//filtro rojo
filtrorojo = RGBChannels[2] - RGBChannels[1]- RGBChannels[0];
}
else
{
filtrorojo.at<uint8_t>(r, c) =
RGBChannels[2].at<uint8_t>(r, c);
filtrorojo.at<uint8_t>(r, c) = img.at<Vec3b>(r,
c)[2];
}
}
}
rgb_union[2] = filtrorojo;
rgb_union[1] = RGBChannels[1];
rgb_union[0] = RGBChannels[0];
merge(rgb_union, 3, filtro_final);
imshow("Filtro final", filtro_final);
imshow("canal rojo", rgb_union[2]);
imshow("canal verde", rgb_union[1]);
imshow("canal azul", rgb_union[0]);
if (waitKey(1) == 27)
break;
}
return 0;
}
FUNCIONAMIENTO
El algoritmo filtra el color rojo solo del mouse, se puede mejorar el algoritmo
seleccionando el pixel que se desea filtran usando el click del mouse.