0% found this document useful (0 votes)
34 views

Experiment No.9: Write A MATLAB Program To Add Noise To An Image and Remove It Using

This document describes a MATLAB experiment to add and remove noise from an image using median filtering. The experiment loads an image, adds "salt and pepper" noise at 2% density, and then applies a 3x3 median filter to remove the noise. Functions used include imread() to load the image, imnoise() to add noise, medfilt2() for median filtering, and imshow() to display the images. The experiment is conducted on a grayscale image and color image, with median filtering demonstrated as an effective way to remove noise from digital images.

Uploaded by

paunikarswati6
Copyright
© Attribution Non-Commercial (BY-NC)
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)
34 views

Experiment No.9: Write A MATLAB Program To Add Noise To An Image and Remove It Using

This document describes a MATLAB experiment to add and remove noise from an image using median filtering. The experiment loads an image, adds "salt and pepper" noise at 2% density, and then applies a 3x3 median filter to remove the noise. Functions used include imread() to load the image, imnoise() to add noise, medfilt2() for median filtering, and imshow() to display the images. The experiment is conducted on a grayscale image and color image, with median filtering demonstrated as an effective way to remove noise from digital images.

Uploaded by

paunikarswati6
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 5

Digital Signal Processing lab

B.E. VII SEM

EXPERIMENT NO.9
AIM:- Write a MATLAB program to add noise to an image and remove it using
MEDIAN FILTER

SOFTWARE: MATLAB THEORY:


In electrical engineering and computer science, image processing is any form of signal processing for which the input is an image, such as a photograph or video frame; the output of image processing may be either an image or, a set of characteristics or parameters related to the image. Most image-processing techniques involve treating the image as a twodimensional signal and applying standard signal-processing techniques to it. Image processing usually refers to digital image processing, but optical and analog image processing also are possible. This article is about general techniques that apply to all of them. The acquisition of images (producing the input image in the first place) is referred to as imaging.

Color corrections such as brightness and contrast adjustments, color mapping, color balancing, quantization, or color translation to a different color space Digital compositing or optical compositing (combination of two or more images), which is used in film-making to make a "matte" Image registration, the alignment of two or more images Image recognition, for example, may extract the text from the image using optical character recognition or checkbox and bubble values using optical mark recognition Image segmentation

The Digital

image

processing is

the

use

of

computer algorithms to

perform image

processing on digital images. As a subcategory or field of digital signal processing, digital image processing has many advantages over analog image processing. It allows a much wider range of algorithms to be applied to the input data and can avoid problems such as the build-up of noise and signal distortion during processing.

NYSSCER, Nagpur

Digital Signal Processing lab

B.E. VII SEM

FUNCTIONS USED: 1.imshow


Display image

Syntax
imshow(I) imshow(RGB)

Description
imshow(I) displays the grayscale image I. imshow(RGB) displays the truecolor image RGB.

2.imread
Read image from graphics file

Syntax
A = imread(filename, fmt)

Description
A = imread(filename, fmt) reads a grayscale or color image from the file specified by the string filename. If the file is not in the current directory, or in a directory on the MATLAB path, specify the full pathname.

3.imnoise
Add noise to image

Syntax
J = imnoise(I,type)

Description
NYSSCER, Nagpur

Digital Signal Processing lab

B.E. VII SEM

J = imnoise(I,type) adds noise of a given type to the intensity image I. type is a string that can have one of these values.

4. medfilt2
2-D median filtering

Syntax
B = medfilt2(A, [m n])

Description
B = medfilt2(A, [m n]) performs median filtering of the matrix A in two dimensions. Each output pixel contains the median value in the m-by-n neighborhood around the corresponding pixel in the input image. medfilt2 pads the image with 0s on the edges, so the median values for the points within [m n]/2 of the edges might appear distorted.

5.imfilter
N-D filtering of multidimensional images

Syntax
B = imfilter(A, H) B = imfilter(A, H, option1, option2,...)

Description
B = imfilter(A, H) filters the multidimensional array A with the multidimensional filter H. The array A can be logical or a nonsparse numeric array of any class and dimension. The result B has the same size and class as A. Each element of the output B is computed using double-precision floating point. If A is an integer or logical array, then output elements that exceed the range of the integer type are truncated, and fractional values are rounded.

NYSSCER, Nagpur

Digital Signal Processing lab

B.E. VII SEM

%EXPT 9:Write a MATLAB program to add noise to an image and remove it using MEDIAN FILTER clc; clear all; close all; a=imread('eight.tif'); subplot(1,3,1); imshow(a); b=imnoise(a,'salt & pepper',0.02); subplot(1,3,2); imshow(b); c=medfilt2(b,[3 3]); subplot(1,3,3); imshow(c);

NYSSCER, Nagpur

Digital Signal Processing lab

B.E. VII SEM

%EXPT 9:Write a MATLAB program to add noise to an image and remove it using MEDIAN FILTER clc; clear all; close all; a=imread('C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg'); subplot(1,3,1); imshow(a); b=imnoise(a,'salt & pepper',0.02); subplot(1,3,2); imshow(b); h = ones(5,5)/25; c=imfilter(a,h); subplot(1,3,3); imshow(c);

CONCLUSION:
Studied about the MEDIAN FILTER and addition & removal of noise to a grey and RGB image.
NYSSCER, Nagpur

You might also like