0% found this document useful (0 votes)
30 views8 pages

Experiment - 2: AIM: To Convert RGB Image To Grayscale Image

The document describes a series of image processing experiments. Experiment 1 converts a color image to grayscale. Experiment 2 applies a histogram function to the grayscale image. Experiment 3 adds different types of noise (salt and pepper, Gaussian, Poisson) to the original image. Experiment 4 extracts the individual red, green, and blue color components from the image. Experiment 5 performs edge detection on the image using Sobel and Canny edge detection methods.

Uploaded by

Harpreet Saini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views8 pages

Experiment - 2: AIM: To Convert RGB Image To Grayscale Image

The document describes a series of image processing experiments. Experiment 1 converts a color image to grayscale. Experiment 2 applies a histogram function to the grayscale image. Experiment 3 adds different types of noise (salt and pepper, Gaussian, Poisson) to the original image. Experiment 4 extracts the individual red, green, and blue color components from the image. Experiment 5 performs edge detection on the image using Sobel and Canny edge detection methods.

Uploaded by

Harpreet Saini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

EXPERIMENT 2

AIM: To convert rgb image to grayscale image.

clear all
close all
I = imread('C:\Users\Harpreet Kaur\Pictures\newww.jpg');

subplot(2,1,1);

imshow(I)
title('ORIGINAL IMAGE');

j=rgb2gray(I)
subplot(2,1,2);
imshow(j)
title('GRAY SCALED IMAGE');
imwrite (j, 'C:\Users\Harpreet Kaur\Pictures\j.png');
EXPERIMENT 3
AIM: To apply histogram function.

clear all
close all
I = imread('C:\Users\Harpreet Kaur\Pictures\newww.jpg');
a=rgb2gray(I)
subplot(2,2,1);
imshow(a)
title('gray scaled image')
subplot(2,2,2);
imhist(a)
title('histogram')

b=histeq(a)
subplot(2,2,3)
imshow(b)
title('equalised image')

subplot(2,2,4)
imhist(b)
title('equalised histogram')
EXPERIMENT 4
AIM WAP to add noise in the image.
close all
I = imread('C:\Users\Harpreet Kaur\Pictures\newww.jpg');
subplot(2,2,1);
imshow(I)
title('original image')
noise=imnoise(I,'salt & pepper',0.05);
subplot(2,2,2)
imshow(noise)
title('salt & pepper')

noise=imnoise(I,'gaussian',0.05,0.02);
subplot(2,2,3)
imshow(noise)
title('gaussian')

noise=imnoise(I,'poisson');
subplot(2,2,4)
imshow(noise)
title('poisson')
Experiment 5

Aim Wap to extract RGB component of color image.

clear all
close all
I = imread('C:\Users\Harpreet Kaur\Pictures\newww.jpg');
subplot(2,2,1);
imshow(I)
title('ORIGINAL IMAGE');

red=I
blue=I
green=I

red(:,:,2:3)=0
subplot(2,2,2)
imshow(red);
title('RED COMPONENT');

green(:,:,1)=0
green(:,:,3)=0
subplot(2,2,3)
imshow(green)
title('GREEN COMPONENT');
blue(:,:,1:2)=0
subplot(2,2,4)
imshow(blue)
title('BLUE COMPONENT');

Experiment 6

Aim edge detection

clc;
x=imread ('C:/Users/student/Desktop/Penguins.jpg');
figure();
imshow(x);
title('jpg');
bw=rgb2gray(x);
subplot(2,2,1);
imshow(bw);
title('b/w');
n=edge(bw);
subplot(2,2,2);
imshow(n);
title('sobeledge');
t=edge(bw,'canny');
subplot(2,2,3);
imshow(t);
title('cannyedge');

You might also like