Download \'Balloon.tif\' image. Write a MATLAB script to complete the following
ID: 3821405 • Letter: D
Question
Download 'Balloon.tif' image. Write a MATLAB script to complete the following tasks: Load image 'Balloon.tif develop a function to mark all pixels in green with 1 and 0 for the rest. Display the result image Convert it into a grayscale image, denoted with 'img1' Create a copy of the clean grayscale image, denoted with 'img2', in the memory and add salt and pepper noise to it using imnoise Remove salt and pepper noise using function medfilt2 and display the clean (img1) and denoted image side by side (using subplot function) create a copy of the clean grayscale image, denoted with 'img3', in the memory and add Gaussian noise using imnoise. Remove Gaussian noise using imgaussfilt Enhance the denoised img3 to recover the fine edges The program(s) must be implemented with MATLAB. Submit the source code of your program. Within the program, use comment lines to describe how to execute the program to demonstrate the above actions.Explanation / Answer
function returnedImage = toGrayscale(image)
i = image;
R = i(:, :, 1);
G = i(:, :, 2);
B = i(:, :, 3);
newImage = zeros(size(i,1), size(i,2), 'uint8');
for x=1:size(i,1)
for y=1:size(i,2)
newImage(x,y) = (R(x,y)*.3)+(G(x,y)*.6)+(B(x,y)*.1);
end
end
returnedImage = newImage;
end
img=imread('ballon.tif')
%col=img.size()
img1=rgb2gray(img)
img2=toGrayScale(img1)
%adding salt and pepper noise
noise = imnoise(img2,'salt & pepper',0.02);
%Denoising image
denoise = medfilt2(noise);
% ploting img1 and denoise image
subplot(1,2,1)
subimage(img1)
title('Image 1')
subplot(1,2,2)
subimage(denoise)
title('Denoised image')
img3=toGrayScale(img1)
%adding gaussian noise to img3
noise1=imnoise(img3,'gaussian',0.02)
Iblur = imgaussfilt(noise, 2);
%Enhancing the image
smoothedImage = imguidedfilter(Iblur, 'NeighborhoodSize',[19 19]);
finalImage = imadjust(smoothedImage);
imshowpair(img3, finalImage, 'montage');
axis on;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.