Skip to content

Instantly share code, notes, and snippets.

@krishnan793
Created April 30, 2015 06:50
Show Gist options
  • Save krishnan793/bb9c7048137a25aa49a1 to your computer and use it in GitHub Desktop.
Save krishnan793/bb9c7048137a25aa49a1 to your computer and use it in GitHub Desktop.
Program reads a picture file called boy.jpg in the current folder and displays it. After 1 second it will change to grey scale.
#include<highgui.h>
#include<cv.h>
using namespace cv;
int main()
{
Mat A,B;
A=imread("boy.jpg"); //Read the image file
namedWindow("Boy", CV_WINDOW_AUTOSIZE ); //Create a new window to show the image. Name the window as "boy"
cvtColor(A,B,CV_BGR2GRAY); //To convert bgr (blue green red) to greyscale and store it in B
imshow("Boy",A); //Display it in the window named Boy
cvWaitKey(1000); //Delay of 1 second
imshow("Boy",B); //Display Second Image
cvWaitKey(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment