0% found this document useful (0 votes)
49 views4 pages

Exam

The document discusses various image processing techniques in MATLAB including reading images, converting between color spaces (RGB to grayscale, binary), resizing images, adding noise, and filtering noise using median, wiener and average filters. Example code is provided to load tiger.img, add salt and pepper noise, and filter it using median filtering. Further examples demonstrate converting images to grayscale and binary, resizing, and applying different filters like median, wiener, and average to remove noise.

Uploaded by

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

Exam

The document discusses various image processing techniques in MATLAB including reading images, converting between color spaces (RGB to grayscale, binary), resizing images, adding noise, and filtering noise using median, wiener and average filters. Example code is provided to load tiger.img, add salt and pepper noise, and filter it using median filtering. Further examples demonstrate converting images to grayscale and binary, resizing, and applying different filters like median, wiener, and average to remove noise.

Uploaded by

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

LAB1

RGB = imread('C:\Users\abu\Desktop\nova\tiger.img');
figure, imshow(RGB)
I = rgb2gray(RGB); % converting rgb image to grayscale image
figure, imshow(I);
im = im2bw(I); % converting rgb image to binary image
figure, imshow(im);
[X,map] = imread('tiger.img');
imshow(X,map);
i=imread('C:\Users\abu\Desktop\nova\tiger.img');
subplot(221);
figure,imshow(i);
title('Working Matlab Editor');% how to give the matlab titles on the image
j=rgb2gray(i); %converting from color image to grayscale
subplot(222);
imshow(j);
k=im2bw(j); %converting grayscale image to binary image
subplot(223);
imshow(k);
N = imresize(k, 0.5);
figure(2),imshow(N);
% adding a noise to the image and how to filter noize of the image
Im1=imread('C:\Users\abu\Desktop\nova\tiger.img');
imshow(Im1);
J=imnoise(Im1,'salt & pepper',0.02);
K=medfilt3(J);
imshow(J), figure, imshow(K);

RGB = imread('C:\Users\abu\Desktop\nova\tiger.img');
figure, imshow(RGB)
I = rgb2gray(RGB); % converting rgb image to grayscale image
figure, imshow(I);
im = im2bw(I); % converting rgb image to binary image
figure, imshow(im);
[X,map] = imread('tiger.img');
imshow(X,map);
i=imread('C:\Users\abu\Desktop\nova\tiger.img');
subplot(221);
figure,imshow(i);
title('Working Matlab Editor');% how to give the matlab titles on the image
j=rgb2gray(i); %converting from color image to grayscale
subplot(222);
imshow(j);
k=im2bw(j); %converting grayscale image to binary image
subplot(223);
imshow(k);
N = imresize(k, 0.5);
figure(2),imshow(N);
% adding a noise to the image and how to filter noize of the image
Im1=imread('C:\Users\abu\Desktop\nova\tiger.img');
imshow(Im1);
J=imnoise(Im1,'salt & pepper',0.02);
K=medfilt3(J);
imshow(J), figure, imshow(K);
filtering
Imr=imread('Lena1.jpg');
Im=rgb2gray(Imr);
noizy=imnoise(Im,'salt & pepper',0.1);
[m,n]=size(noizy);
output=zeros(m,n);
%output=unit8(output);
for i=1:m
for j=1:m
xmin=max(1,i-1);
xmax=min(m,i+1);
ymin=max(1,j-1);
ymax=min(m,j+1);
temp=noizy(xmin:xmax,ymin:ymax);
output(i,j)=median(temp(:));

end
end
figure(1);
set(gcf,'positon',get(0,'ScreenSize'));
Subplot(131),imshow(Imr), title('Original Image');
Subplot(132),imshow(Im), title('Noizy Image');
Subplot(133),imshow(noizy), title('Median filtered Image');

LAB2
i=imread('A1.jpg');
subplot(221);
imshow(i);
title('Original image');
title('Working Matlab Editor');% how to give the matlab titles on the image

%matlab

%lab sessions
%resizing images
%converting rgb image to binary
%and gray scale
% Ploting figures
%properties of image
%figure vs subplot
Img=imread('C:\Users\Dell\Desktop\matl\lena1.jpg');
figure,imshow(Img);
title('Orignal Image');
whos Img;
Imgg=imresize(Img,2);
figure,imshow(Imgg);
title('Resized Image');
whos Imgg;
Img1=rgb2gray(Img);
figure,imshow(Img1);
title('Grayscale Image');
whos Img1;
k=im2bw(Img1);
figure, imshow(k);
title('Binary image');
whos k;

////////////////////
Img=imread('C:\Users\Dell\Desktop\matl\lena1.jpg');
subplot(221),imshow(Img);
title('Orignal Image');
whos Img;
Imgg=imresize(Img,2);
subplot(222),imshow(Imgg);
title('Resized Image');
whos Imgg;
Img1=rgb2gray(Img);
subplot(223),imshow(Img1);
title('Grayscale Image');
whos Img1;
k=im2bw(Img1);
subplot(224), imshow(k);
title('Binary image');
whos k;

%converting grayscale image to binary image


subplot(223);
imshow(k);
title('Binary image');
N = imresize(k, 2);
figure(2),imshow(N);
title('Resized Image');

MID FILTERING

Img1=imread('LL.png');
[h,w]=size(Img1);
figure(1), imshow(Img1);
title ('Orignal image');
%resize
N = imresize(Img1, 0.5);
figure(2),imshow(N);
title(' Rezised Image');
% Adding Noise to The Image
J = imnoise(Img1,'salt & pepper',0.01);
figure(3), imshow(J);
title(' image with salt and Noise 0.01 ');
J = imnoise(N,'salt & pepper',0.2);
figure(4),imshow(J);
title ('Image with noise level salt and 0.4');
%Before binarization
b1=rgb2gray(J);
a=medfilt2(b1,[3,3]);
figure(5), imshow(a);
title ('Median Filtered Image');
K = wiener2(a,[1.5 1.5]);
figure(6), imshow(K);
title('wiener2 filtered image');
% Average filtering
P = filter2(fspecial('average',2),Img1)/255;
figure(7), imshow(P);
title ('Average filtering');
%After binarization
BW=dither(Img1);
figure(8),imshow(BW);
title ('Binary Image');
BW1 = im2bw(Img1);
figure(9),imshow(BW1);
title ('Gray scale image');
%%im2bw(I,level);% converts grayscale image to a binary Img1;
%level is in the range [0,1]
BW2 = im2bw(Img1, 0.6);
figure(10),imshow(BW2);
title ('RGB to a binary Img1');
%converts the truecolor Img1 RGB to a binary Img1
%Gaussian filter using MATLAB built_in function
%Read an Image
A = imnoise(Img1,'Gaussian',0.02,0.03);
%Image with noise
figure(11),imshow(A);
title('Gaussian Imgae Noise');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy