Report 1 - Image Processing

download Report 1 - Image Processing

of 6

Transcript of Report 1 - Image Processing

  • 7/30/2019 Report 1 - Image Processing

    1/6

    2

    1. Display of an image

    First, we have prepared the image. The image was chosen from the internet and it was chosen such that

    it has many colors and intensities. The image size is 512 x 512. To display the image in Matlab, the

    following command has been used:

    Figure 1: Matlab code for reading an image from current workspace.

    The result is that the image will be displayed, as seen in the figure below:

    Figure 2: Original image.

    2. Separation of a color imageHaving the image displayed, we can now perform the separation of the color image. We can separate

    the image into R, G, B component images, respectively. The separation and the displaying of the images

    were done using the following code:

  • 7/30/2019 Report 1 - Image Processing

    2/6

    3

    Figure 3: Matlab code for separating the original image into R, G, B components.

    To separate the components, we have to understand that the image is represented as a 3D matrix. Each

    pixel from the image contains R, G and B information. Thus, we can separate these components by

    selecting each component from the image: 1st

    component is the R component, 2nd

    component is the G

    component and 3rd

    component is the B component.

    The results of running this code is that we will have 3 images, each containing the R, G, B components of

    the original image, respectively. The results are shown below:

    Figure 4: Image containing the R component of the original image.

  • 7/30/2019 Report 1 - Image Processing

    3/6

    4

    Figure 5: Image containing the G component of the original image.

    Figure 6: Image containing the B component of the original image.

    We notice that the obtained pictures are different, depending on the represented component.

  • 7/30/2019 Report 1 - Image Processing

    4/6

    5

    3. Conversion of color image into grayscale image.

    The next operation is to convert the image into a grayscale image. One method was the one using the

    rgb2ntsc function in Matlab. Another method was used, in order to check the results with the first

    method, by using another Matlab function named rgb2gray.

    The first method is using the function rgb2ntsc. This function converts RGB color values to NTSC color

    space. In other words, this function converts the true color image RGB to the equivalent NTSC image YIQ

    (Y = luminance, I and Q are chrominance). After applying this function we have to select the Y

    component from the image. We do this because the Y component is the luminance and it contains the

    grayscale signal used to display pictures on monochrome (black and white) televisions. The other

    components carry the hue and saturation information.

    The above has been implemented in Matlab in the following way:

    Figure 7: Matlab code for converting the image into NTSC color space and selecting the Y component.

    The obtained NTSC color space image is:

  • 7/30/2019 Report 1 - Image Processing

    5/6

    6

    Figure 8: The converted image into NTSC color space.

    Then, from this image, we have to select the Y component in order to represent the grayscale image.

    The result is shown below:

    Figure 9: Image containing the Y component from the NTSC color space image (the grayscale image).

  • 7/30/2019 Report 1 - Image Processing

    6/6

    7

    Now, we can try another method for obtaining the grayscale image, in order to verify that the previous

    method has, indeed, produced the right result. There is another Matlab function, called rgb2graythat

    can directly convert an RGB image into grayscale image. The Matlab code for this function is shown

    below:

    Figure 10: Matlab code for implementing another method to convert the original image into grayscale

    image.

    The resulted image is shown:

    Figure 11: Grayscale image obtained using the Matlab function rgb2gray.

    As we can see, the same image as in Figure 9 has been obtained. It means that indeed the results are

    correct.