Tuesday, 13 March 2012

IMAGE ACQUISITION AND BASIC OPERATION(MATLAB)

IMAGE PROCESSING TOOLBOX


In this lab, we have performed some basic image processing exercise by matlab. The main purpose of this lab is to :
1.       Read and display image
2.       Check how the image appears in the workspace
3.       Perform histogram equalization on the image
4.       Write the image to a disk file
5.       Get information about graphic file



Below is the commands and example output:

>>I = imread (‘pout2.png’)     % Output the array

>>Imshow(I)                          % To display image

Original   'pout2.png'



>>whos    % To see how I is stored in memory
Input and output of 'whos' command



>>figure, imhist(I)    % To display histogram of I in the new figure

Histogram equilization




>>I2 = histeq(I)      %Equalize I and output in new array

>>figure, imshow(I2)    %Display the new equalized image I2.




Equilized   'pout2.png'



>>imwrite(I2, 'pout2.png')      % To write the newly adjusted image I2 back to disk.

>>imfinfo(‘pout2.png’)     % To check the content of newly written file

Check info







Next, we also learn on how to edit image
This command shows original image

>> x = imread ('obama.png');
>> figure,  imshow (x)

The original image


This command functions to convert original image to be gray scaled:
>> x_g = rgb2gray(x);
>> figure, imshow (x_g)


The image has been converted to gray scale


This command allow cropping image:-
>> imshow (x_g' imcrop);



This command function will flip the image:

>> figure(1); image(x)
x(:, :, 1) = fliplr (x(:, :, 1));
x(:, :, 2) = fliplr (x(:, :, 2)); 
x(:, :, 3) = fliplr (x(:, :, 3)); 
figure(2); image(x)


The flipped image


Commands function below will show how an image being flipped vertically and horizontally

>> xMirror = flipdim(x,2);             % horizontal flip
>>  xUpsideDown = flipdim(x,1);  % vertical flip
>> xHorizontalAndVerticalFlip = flipdim (xUpsideDown, 2);  % horizontal and vertical flip

>> subplot(2,2,1), imshow(x)
>> subplot(2,2,2), imshow(xMirror)
>> subplot(2,2,3), imshow(xUpsideDown)
>> subplot(2,2,4), imshow(xHorizontalAndVerticalFlip)

Flipped image in both vertical and horizontal









Image info by using command function >> iminfo(x)



No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...