Skip to content

Instantly share code, notes, and snippets.

@abhinavjain241
Created December 1, 2014 07:56
Show Gist options
  • Save abhinavjain241/005cedca49b96faa18b3 to your computer and use it in GitHub Desktop.
Save abhinavjain241/005cedca49b96faa18b3 to your computer and use it in GitHub Desktop.
Generate Striped Image
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image(200,300,CV_8UC3,Scalar(0,0,255));
char win[] = "Striped Image"; //String with the name of the window
int location;
for(int i=0; i<image.rows;i++)
{
for(int j=0;j<image.cols;j++)
{
image.at<Vec3b>(i,j)[0]=0;
image.at<Vec3b>(i,j)[1]=0;
image.at<Vec3b>(i,j)[2]=0;
if(i<image.rows/3)
image.at<Vec3b>(i,j)[0]=255; //Blue
else if(i>=(2*image.rows)/3)
image.at<Vec3b>(i,j)[2]=255; //Red
else
image.at<Vec3b>(i,j)[1]=255; //Green
}
}
namedWindow(win,CV_WINDOW_AUTOSIZE);
imshow(win,image);
waitKey(0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment