Displaying image in grayscale

OpenCV provides easy way to load image as IplImage in 3 band format, grayscale format or load image as it is(in its original format). Image loading function loads image from file as IplImage by taking 2 arguments.

  1. Image file name e.g. 'img1.png' in my case.
  2. Color code as integer.
Here is my img1.png file in original format.

We can provide 3 types of color code integers
  • 'CV_LOAD_IMAGE_COLOR'
    This will load image in 3channel color image i.e. RGB image.
    we will use following code and see what will be the result


    The result will be as following image.
    The image is not actually changed as we have given RGB Image and output is also displaying RGB image.

  • 'CV_LOAD_IMAGE_GRYASCALE'
    This will load image in gray scale format.
    we will use following code and see what will be the result


    The result will be as following image.
    The out put image is gray scale version of input image.

  • 'CV_LOAD_IMAGE_UNCHANGED'
    This will load image as it is.
    We can use this format if we want to load image in its original format.

1 comment:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

    ReplyDelete