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

Vikash (RA231102601123) - DIP

The document outlines a procedure for simulating and removing noise from the water region of a color image using digital image processing techniques. It details steps including loading the image, creating a binary mask for the lake, adding Gaussian noise, denoising the image with filters, and extracting a 15x15 pixel patch to display its digital number values. The provided code implements these steps in MATLAB without using the Image Processing Toolbox.

Uploaded by

Anupam Soni
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)
13 views8 pages

Vikash (RA231102601123) - DIP

The document outlines a procedure for simulating and removing noise from the water region of a color image using digital image processing techniques. It details steps including loading the image, creating a binary mask for the lake, adding Gaussian noise, denoising the image with filters, and extracting a 15x15 pixel patch to display its digital number values. The provided code implements these steps in MATLAB without using the Image Processing Toolbox.

Uploaded by

Anupam Soni
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

Digital Image Processing

Impathon

RA2311026011123

Vikash Kumar

Add noise to portion of lake water apply

suitable filter where noise only the factors.

Subset the image with the dimension of

(15x15). Print the DN values from the subset

image for all channels.


Problem –
Simulate and then remove noise confined to the water region of a color
image.

Steps –
1. Load and normalize the image to [0,1].
2. Segment the lake by thresholding its blue channel to create a binary
mask.
3. Add zero-mean Gaussian noise only to pixels within that mask.
4. Denoise the noisy image using either a 5×5 Wiener filter or a 3×3
median filter (no Image Processing Toolbox required).
5. Extract a 15×15-pixel patch from the denoised image (starting at
the first lake pixel) and print its DN values for the red, green, and
blue channels.

Procedure
Load & normalize

I = im2double(imread('/mnt/data/[Link]'));

Mask lake

lakeMask = I(:,:,3) > 0.45;

Add noise only in mask

noisyI = I;

noiseStd = 0.05;

for c=1:3

ch = noisyI(:,:,c);

rnd = noiseStd*randn(size(ch));

ch(lakeMask) = ch(lakeMask)+rnd(lakeMask);

noisyI(:,:,c)=ch;

end

noisyI = min(max(noisyI,0),1);

Denoise w/o IPT

for c=1:3

denoisedI(:,:,c) = wiener2(noisyI(:,:,c),[5 5]);


% or medfilt2(noisyI(:,:,c),[3 3])

end

Extract & print 15×15

[r,c] = find(lakeMask,1);

r0=min(r,size(I,1)-14); c0=min(c,size(I,2)-14);

patch = denoisedI(r0:r0+14,c0:c0+14,:);

disp(patch(:,:,1)); disp(patch(:,:,2)); disp(patch(:,:,3));

Code –
I = imread('[Link]');

I = im2double(I);

blueChan = I(:,:,3);

lakeMask = blueChan > 0.45;

figure;

subplot(1,2,1), imshow(I), title('Original Image');

subplot(1,2,2), imshow(lakeMask), title('Lake Mask');

noisyI = I;

noiseStd = 0.05;

for c = 1:3

ch = noisyI(:,:,c);

rnd = noiseStd * randn(size(ch));

ch(lakeMask) = ch(lakeMask) + rnd(lakeMask);

noisyI(:,:,c) = ch;

end

noisyI = min(max(noisyI,0),1);

figure; imshow(noisyI), title('Noisy in Lake Region');

denoisedI = zeros(size(noisyI));
for c = 1:3

denoisedI(:,:,c) = imbilatfilt(noisyI(:,:,c));

end

figure; imshow(denoisedI), title('After Bilateral Filtering');

[idxR, idxC] = find(lakeMask);

r0 = min(idxR);

c0 = min(idxC);

r0 = min(r0, size(I,1)-14);

c0 = min(c0, size(I,2)-14);

subset = denoisedI(r0:r0+14, c0:c0+14, :);

figure; imshow(subset), title(sprintf('15×15 Patch @(%d,%d)',r0,c0));

fprintf('15×15 subset DN values (rows %d–%d, cols %d–%d):\n', ...

r0, r0+14, c0, c0+14);

for c = 1:3

fprintf('\n— Channel %d —\n', c);

disp(subset(:,:,c));

end

15×15 subset DN values (rows 1–15, cols 1–15):

Screenshots (Output) :-

You might also like