Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Image Conversion

Image Conversion and Enhancement Using MATLAB

OBJECTIVES

To familiar with MATLAB functions for image conversion

To use MATLAB functions for image histogram equalization

To use MATLAB functions for image noise filtering

PROCEDURE:

Part A: Image Format and Conversion

1. Use the following code and image data “trees.jpg” provided by your instructor to display the image

>XX=imread('trees','JPEG');

>figure, imshow(XX);

To display the size of the image data, try the following

> size(XX)

What is the image size (bytes)? ________________________

Repeat (1) using the following code and the indexed image data “clipim2,gif” provided by your instructor to display the image

>[Xind map]=imread('clipim2','gif');

>figure, imshow(Xind, map);

To display the size and colormap size of the indexed image, try the following

> size(Xind)

> size (map)

What is the image size (bytes)? ________________________

What is the color map size (number of color table entries)? ___________________________

2. Try the following code to convert the color image to a grayscale image:

>Y=rgb2gray(XX);

>imshow(Y);

What is the image size (bytes)? ________________________

For the indexed image, try

> Yind=ind2gray(Xind,map);

> imshow(Yind)

What is the image size (bytes)? ________________________

Part B: Image Histogram Equalization

1. Image taken under light exposure can be enhanced to show more details using the image histogram equalization.

a. Try the following codes for the grayscale image equalization:

Y=rgb2gray(XX);

figure, subplot(1,2,1);imshow(Y);

title('original');subplot(1,2,2);imhist(Y, 256);

disp('Equalization in grayscale domain');

Y=histeq(Y);

figure, subplot(1,2,1); imshow(Y);

title('EQ in grayscale-domain'); subplot(1,2,2); imhist(Y, 256);

b. Try the following codes for RGB color image equalization.

disp('Equalization of Y channel for RGB color image');

subplot(1,2,1); imshow(XX);

title('EQ in RGB color');

subplot(1,2,2); imhist(rgb2gray(XX),256);

Z1=rgb2ntsc(XX); % conversion from RGB to YIQ

Z1(:,:,1)=histeq(Z1(:,:,1)); %equalizing Y channel;

ZZ=ntsc2rgb(Z1); %conversion from YIQ to RGB

figure

subplot(1,2,1); imshow(ZZ);

title('EQ for Y channel for RGB color image');

subplot(1,2,2); imhist(im2uint8(rgb2gray(ZZ)),256);

c. Try the following MATLAB program for equalizing the 8-bit indexed color image

disp('Eqlization in 8-bit indexd color');

[Xind, map]=rgb2ind(XX, 256); % rgb to 8-bit index image conversion

newmap=histeq(Xind,map);

figure

subplot(1,2,1); imshow(Xind,newmap);

title('EQ in 8-bit indexed color');

subplot(1,2,2); imhist(ind2gray(Xind,newmap),256);

Try (c) using the image “clipim2.gif.

Part C: Image Noise Filtering

In this lab, we focus on filtering noise in the grayscale image. Obtain the grayscale image provided by your instructor.

X=imread('cruise','jpeg'); % provided by the instructor

Y=rgb2gray(X); % convert the rgb image to the

Then create the noise image for use by the following steps: obtain the intensity image, generate the noisy image by adding the Gaussian random noise, and rescale back to the 8-bit grayscale image.

Try following:

I=im2double(Y); % get the intensity image

image1_g=imnoise(I,'gaussian'); % add random noise to the intensity image

ng=mat2gray(image1_g); % adjust the range

ng=im2uint8(ng); % 8-bit corrupted image

Try the following codes for linear filtering using the Gaussian filter.

%Linear Filtering

K_size= 5; % Kernel size = 5x5

sigma =0.8; % alpha = 0.8

h=fspecial('gaussian',K_size,sigma); % determine Gaussian filter

image1_out=filter2(h,image1_g); % perform filtering

image1_out=mat2gray(image1_out); % adjust the range

image1_out=im2uint8(image1_out); % get the 8-bit image

subplot(1,2,1); imshow(ng),title('Noisy image');

subplot(1,2,2); imshow(image1_out);

title('5x5 Gaussian kernel');

Repeat the filtering by choosing:

(1) K_size=5, and sigma=0.5, and sigma = 1, sigma=10, respectively, and comment on your results.

(2) K_size=15, and sigma=0.5, and sigma = 1, sigma=10, respectively, and comment on your results.

b. Median filtering is an efficient way to remove the “salt and pepper” noise in the corrupted image.

Try the following codes:

image1_s=imnoise(I,'salt & pepper'); % add “salt and peper” noise to image

mn=mat2gray(image1_s); % adjust range

mn=im2uint8(mn); % get the 8-bit image

K_size=3; % kernel size

image1_m=medfilt2(image1_s,[K_size, K_size]); % perform median filtering

image1_m=mat2gray(image1_m); % adjust range

image1_m=im2uint8(image1_m); % get the 8-bit image

figure, subplot(1,2,1);imshow(mn)

title('Median noisy');

subplot(1,2,2);imshow(image1_m);

title('3x3 medina kernel');

Repeat (b) for K_size =2, K_size=5, K_size=10, and comment on your results.

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.