Tuesday, 13 March 2012

Lab 2 - Image Acquisition and Basic Operation

,
Objective: To learn the basic operations related to image acquisition

Question 1:

a) Copy image, 'Porsche.tiff' into any directory. Example; C:\Users\abc\Desktop. Also can use another pictures. Read the file. How large is the image (rows, columns)?

Porsche.tiff

Answer:

- Use command imread to read the file. Refer to Lab 1 in previous entry (click here).
- Before that, make sure your current directory in Matlab is the same as the location of the image ('Porsche.tiff') that have been saved. Example; C:\Users\abc\Desktop


  >> I=imread('Porsche.tiff')

To check how large is the image (rows and columns), go to Matlab workspace.


Value = <342x546 uint8>
Rows = 342
Columns = 546

Or, double click (open I) I in workspace.


Variable editor of I will be displayed.


You can scroll the scroll bar to check the rows and columns.

b) Answer the following questions about the image:

How big is the file (bytes)?
- Use whos command

  >> whos


Answer: 186732 Bytes

- How large is the image (rows, columns)?

Answer: Rows = 342, Columns = 546

- What are the minimum and maximum grey values?

Check at workspace.

Answer: Min = 0, Max = 240


Question 2

Part I: Image Acquisition
- Use your own picture.

baby.jpg

Part II: Read the image into Matlab
- Use imread command to read the image you have acquired in Part I.

  >> I=imread('baby.jpg')

- Display the information of matrix I.

  >> whos


The class should be "uint8" and the third dimension of I should be 3, which denotes it is a color image (the three components correspond to R,G,B channels respectively - e.g; blue channel is given by I(:,:,3).

- Display image to see the original colour.

  >>imshow(I)


- Convert the image into grayscale.

  >> I2 = I(:,:,3);

Then, display the new I2 to see how the image converted into grayscale mode.

  >> imshow(I2)


- Display the green channel of the image.

   Use grayscale image (I2).

  >> figure, imshow(I2),colormap([zeros(256,1),[0:1/255:1]',zeros(256,1)]),colorbar




*Additional task - convert into red channel.

  >> figure, imshow(I2),colormap([[0:1/255:1]', zeros(256,1),zeros(256,1)]),colorbar




Part III: Basic Image Operations

-Transport the image and display it.


  >> I3=ctranspose(I2);
  >> imshow(I3)


- Crop the top-left quarter of the image and display it.


  >> I4 = imcrop(I,[60 40 80 90]);
  >> imshow(I4)



- Flip the image left to right and display it.


  >> I5 = fliplr(I2);
  >> imshow(I5)



0 comments to “Lab 2 - Image Acquisition and Basic Operation”

Post a Comment

 

FairuZatul Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger Templates