Created
February 12, 2018 23:59
-
-
Save esmarr58/b215d29ee0a0524520db8d65e7269e5e to your computer and use it in GitHub Desktop.
This file contains 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
MainWindow::MainWindow(QWidget *parent) : | |
QMainWindow(parent), | |
ui(new Ui::MainWindow) | |
{ | |
ui->setupUi(this); | |
//Paso # 1 - Se lee una imagen de 3 canales con imread | |
Mat IMAGEN = imread("../imagen1.jpg"); | |
//Paso # 1a - se reducirá la imagen para QT | |
Mat IMAGENchica; | |
cv::resize(IMAGEN,IMAGENchica,Size(250,250)); | |
//Paso # 2 - Se declará una matriz negra de 1 canal | |
Mat imgNegra; | |
imgNegra = Mat::zeros(Size(IMAGENchica.cols,IMAGENchica.rows),CV_8UC1); | |
//IMAGENchica.cols, define la cantidad de columnas de la matriz negra | |
//IMAGENchica.rows, define la cantidad de filas de la matriz negra | |
//CV_8UC1 8 bits sin signo 1 canal. | |
//Paso # 3 - Descomponer la imagen original en 3 imagenes de 3 canales. | |
Mat M1[3]; | |
cv::split(IMAGENchica,M1); | |
//Paso # 4 - Componer la imagen para el canal Azul, canal 0 | |
vector<Mat> IMGtemporal; | |
IMGtemporal.push_back(M1[0]); | |
IMGtemporal.push_back(imgNegra); | |
IMGtemporal.push_back(imgNegra); | |
//Paso # 4a - Se conforma la imagen Azul | |
Mat IMGazul; | |
cv::merge(IMGtemporal,IMGazul); | |
//Paso # 5 - Componer la imagen para el canal Verde, canal 1 | |
vector<Mat> IMGtemporal2; | |
IMGtemporal2.push_back(imgNegra); | |
IMGtemporal2.push_back(M1[1]); | |
IMGtemporal2.push_back(imgNegra); | |
//Paso # 5b - Se conforma la imagen Verde | |
Mat IMGverde; | |
cv::merge(IMGtemporal2,IMGverde); | |
//Paso # 6 - Componer la imagen para el canal Roja, canal 2 | |
vector<Mat> IMGtemporal3; | |
IMGtemporal3.push_back(imgNegra); | |
IMGtemporal3.push_back(imgNegra); | |
IMGtemporal3.push_back(M1[2]); | |
Mat IMGroja; | |
cv::merge(IMGtemporal3,IMGroja); | |
//Mostrar las imagenes con QT y Mat2Qimage.cpp | |
ui->label->clear(); | |
QImage img1 = Mat2QImage(IMAGENchica); | |
QPixmap img2 = QPixmap::fromImage(img1); | |
ui->label->setPixmap(img2); | |
ui->label_2->clear(); | |
img1 = Mat2QImage(IMGazul); | |
img2 = QPixmap::fromImage(img1); | |
ui->label_2->setPixmap(img2); | |
ui->label_3->clear(); | |
img1 = Mat2QImage(IMGverde); | |
img2 = QPixmap::fromImage(img1); | |
ui->label_3->setPixmap(img2); | |
ui->label_4->clear(); | |
img1 = Mat2QImage(IMGroja); | |
img2 = QPixmap::fromImage(img1); | |
ui->label_4->setPixmap(img2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment