What is an Image in Computer Vision

Image is a two dimensional array of pixels, i.e.
Where each pixel represent the intensity. Pixels are represented by numbers. Each number represent a color. 0 Represent black while 255 represent white. This type of image is 8bit image. I.e. 0=00000000, and max value 255=11111111. Another type of image is 16 bit image, which ranges from 0 to 65535.
Types  :
  1. Gray Scale Image 
  2. RGB Image

Gray Scale Image

The image in which the colors are only shades of gray are known as gray scale image(Black and white). Example of grey scale image is.

RGB Image 

Another type of image is RGB image. An RGB image is the combination of Red, Green and Blue image

Red Green Blue of image

The Difference between these two types of images is that the Gray scale image is a single 2-dimensional matrix while RGB image is a combination of three 2-dimensional matrices.
An RGB image can be converted to gray using the following methods,

                        ->  Average Method
                            R + G + B 
Gray image    =   ------------------
                            3
                        ->  Approximate Method

                   Gray image   =  0.59*R + 0.30*G + 0.11*B

Binary Image

A binary image is a digital image that has only two possible values for each pixel 0 or 1 (Black, white). For binary image a threshold value is set. Below threshold the output is 0 while above threshold value is 1. A binary image looks like this.


How can I read image in Matlab??

To read image in matlab use imread() cammand. Use imshow() to display image.
_________________________________________________________________________________
Example
image=imread('image name.jpg');
imshow(image)

_________________________________________________________________________________
How can I read image in OpenCV??

Lets have an example.
_________________________________________________________________________________
Example
#include<stdio.h>
#include<opencv\cv.h>
#include<opencv\highgui.h>
using namespace cv;
using namespace std;
int main()
{
  Mat cap_img;   // define image matrices
  Mat img=imread("C:\\yourimage.JPG",CV_LOAD_IMAGE_UNCHANGED);
  imshow("image window",img);
  while(1)    
   {
     if(waitKey(10) >= 0) break; // press escape to exit program
   }
}
_________________________________________________________________________________


How can I convert RGB to Gray in Matlab??

To convert image from RGB to Gray use this  rgb2gray() command.
_________________________________________________________________________________
Example
image=imread('image name.jpg');
grayimage=rgb2gray(image);
imshow(grayimage)
_________________________________________________________________________________

How can I convert image to gray scale in OpenCV??

Lets have an example.
_________________________________________________________________________________
Example
#include<stdio.h>
#include<opencv\cv.h>
#include<opencv\highgui.h>
using namespace cv;
using namespace std;
int main()
{
  Mat img;   // define image matrices
  Mat gray_image;
  img=imread("C:\\yourimage.JPG",CV_LOAD_IMAGE_UNCHANGED);
  cvtColor(img, gray_image, CV_BGR2GRAY);// convert to Grayscale 
  imshow("image window",img);
  imshow("Gray scale image",gray_image);
  while(1)    
   {
     if(waitKey(10) >= 0) break; // press escape to exit program
   }
}
_________________________________________________________________________________

How can I convert RGB to binary in Matlab??

To convert image to binary, use im2bw() command,
_________________________________________________________________________________
Example
Image = imread('image');
binimg = im2bw(Image,0.4);
imshow(binimg)
_________________________________________________________________________________

No comments:

Post a Comment

I FEEL AWESOME WHEN YOU COMMENT.