CMakeList.txt
cmake_minimum_required(VERSION 2.8)
project(ex1)
set ( OpenCV_DIR /home/cctv/installCV/share/OpenCV )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( ex1 ex1.cpp )
target_link_libraries( ex1 ${OpenCV_LIBS} )
cpp
#include<stdio.h>
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/imgcodecs.hpp>
#include<opencv2/opencv.hpp>
using namespace cv;
using namespace std;
Mat src,srcGray;
Mat dst,detected_edges;
Mat map_x,map_y;
Mat src_x;
unsigned char *p;
int ind=0;
const char *window_name="Remap demo";
static void update_map(void);
static void update_color(void);
unsigned char color=0;
int main(int arvc,char *argv[])
{ int c=0;
src=imread(argv[1],1);
vector<Mat> bgr_planes;
split(src,bgr_planes);
dst.create(src.size(),src.type());
//imshow(window_name,(bgr_planes[0]+bgr_planes[1]+bgr_planes[2]));
//imshow("Green",bgr_planes[1]);
//imshow("RED",bgr_planes[2]);
for(;;)
{
c=waitKey(100);
if((char)c==27)
{
break;
}
update_color();
imshow("RED",dst);
}
return 0;
}
static void update_color(void)
{
int i,j;
for(j=0;j<src.rows;j++)
{
for(i=0;i<src.cols;i+=3)
{
dst.at<unsigned char>(j,i )=128;
dst.at<unsigned char>(j,i+1)=color;
dst.at<unsigned char>(j,i+2)=0;
}
for(i=src.cols;i<src.cols*2;i+=3)
{
dst.at<unsigned char>(j,i )=128;
dst.at<unsigned char>(j,i+1)=color;
dst.at<unsigned char>(j,i+2)=255;
}
for(i=src.cols*2;i<src.cols*3;i+=3)
{
dst.at<unsigned char>(j,i )=255;
dst.at<unsigned char>(j,i+1)=0;
dst.at<unsigned char>(j,i+2)=color;
}
}
color++;
}