DIP Lab File
DIP Lab File
Program:
clear all;
close all;
clc;
imageinfo = imfinfo("new.jpg");
Output:
Experiment-2
Objective: To Read, Write, and Display an image.
Program:
clear all;
close all;
clc;
Image = imread('new.jpg');
imshow(Image);
NewImage = Image-60;
imwrite(NewImage,'newimage.jpg');
Output:
new.jpg newimage.jpg
Experiment-3
Objective: To separate Red, Green and Blue Channel from RGB Image.
Program:
clc;
clear all;
close all;
Image=imread(‘image.jpg’);
figure
subplot(221);
imshow(Image);
title(‘\bf\fontsize{20}Original Image’);
Red=Image(:,:,1);
Green=Image(:,:,2);
Blue=Image(:,:,3);
subplot(222);
imshow(Red);
title(‘\bf\fontsize{20}Red Channel Grayscale’);
subplot(223);
imshow(Green);
title(‘\bf\fontsize{20}Green Channel Grayscale’);
subplot(224);
imshow(Blue);
title(‘\bf\fontsize{20}Blue Channel Grayscale’);
Output:
Experiment-4
Objective: To convert RGB Image into Red Color, Green Color, and Blue Color Image.
Program:
clc;
clear all;
close all;
Image=imread(‘image.jpg’);
figure
subplot(221);
imshow(Image);
title(‘\bf\fontsize{20}Original Image’);
Red=Image;
Red(:,:,2)=0;
Red(:,:,3)=0;
subplot(222);
imshow(Red);
title(‘\bf\fontsize{20}Red’);
Green=Image;
Green(:,:,1)=0;
Green(:,:,3)=0;
subplot(223);
imshow(Green);
title(‘\bf\fontsize{20}Green’);
Blue=Image;
Blue(:,:,1)=0;
Blue(:,:,2)=0;
subplot(224);
imshow(Blue);
title(‘\bf\fontsize{20}Blue’);
Output:
Experiment-5
Program:
clc;
clear all;
close all;
Image=imread(‘image.jpg’);
GrayImage=rgb2gray(Image);
imshowpair(Image,GrayImage,‘montage’);
Output:
Experiment-6
Program:
clc;
clear all;
close all;
Image=imread(‘image.jpg’);
[Ind,Imap]=rgb2ind(Image,64);
figure
Imagesc(Ind)
colormap(Imap)
Output:
Experiment-7
Program:
clc;
clear all;
close all;
I=imread(‘image.jpg’);
figure
imshow(I)
NI = imresize(I, [130, 110])
figure
imshow(I)
Output:
Experiment-8
Program:
clc;
clear all;
close all;
Image=imread("Image.png");
figure
subplot(121)
imshow(Image)
Addition=imadd(Image,100);
subplot(122)
imshow(Addition)
Subtraction=imsubtract(Image,100);
subplot(122)
imshow(Subtraction)
%Multiply=immultiply(Image,2);
%subplot(122)
%imshow(Multiply)
%Divide=imdivide(Image,2);
%subplot(122)
%imshow(Divide)
Output:
Addition Subtraction
Experiment-9
Program:
clc;
clear all;
close all;
Image=imread(‘Image.png’);
% figure
% imshow(Image)
NewImage=double(Image);
% figure
% imshow(NewImage)
Bitplane0=mode(NewImage,2);
Bitplane1=mode(bitshift(NewImage,-1),2);
Bitplane2=mode(bitshift(NewImage,-2),2);
Bitplane3=mode(bitshift(NewImage,-3),2);
Bitplane4=mode(bitshift(NewImage,-4),2);
Bitplane5=mode(bitshift(NewImage,-5),2);
Bitplane6=mode(bitshift(NewImage,-6),2);
Bitplane7=mode(bitshift(NewImage,-7),2);
figure
subplot(241)
imshow(Bitplane0)
title(‘Bitplane 0’)
subplot(242)
imshow(Bitplane1)
title(‘Bitplane 1’)
subplot(243)
imshow(Bitplane2)
title(‘Bitplane 2’)
subplot(244)
imshow(Bitplane3)
title(‘Bitplane 3’)
subplot(245)
imshow(Bitplane4)
title(‘Bitplane 4’)
subplot(246)
imshow(Bitplane5)
title(‘Bitplane 5’)
subplot(247)
imshow(Bitplane6)
title(‘Bitplane 6’)
subplot(248)
imshow(Bitplane7)
title(‘Bitplane 7’)
Output:
Experiment-10
Program:
clc;
clear all;
close all;
I=imread(‘Image.tif’)
NOT=bitcmp(I)
figure
subplot(121)
imshow(I)
subplot(122)
imshow(NOT)
I1=imread(‘Image.tif’)
I2=imread(‘I.png’)
I1=imresize(I1,[120 120]);
AND=bitand(I1,I2);
figure
subplot(131)
imshow(I1)
subplot(132)
imshow(I2)
subplot(133)
imshow(AND)
OR=bitor(I1,I2);
figure
subplot(131)
imshow(I1)
subplot(132)
imshow(I2)
subplot(133)
imshow(OR)
XOR=bitxor(I1,I2);
figure
subplot(131)
imshow(I1)
subplot(132)
imshow(I2)
subplot(133)
imshow(XOR)
OR=bitor(I1,I2);
NOR=bitcmp(OR);
figure
subplot(131)
imshow(I1)
subplot(132)
imshow(I2)
subplot(133)
imshow(NOR)
AND=bitand(I1,I2);
NAND=bitcmp(AND);
figure
subplot(131)
imshow(I1)
subplot(132)
imshow(I2)
subplot(133)
imshow(NAND)
XOR=bitxor(I1,I2);
XNOR=bitcmp(AND);
figure
subplot(131)
imshow(I1)
subplot(132)
imshow(I2)
subplot(133)
imshow(NAND)
Outputs:
NOR
NAND
XNOR
Experiment-11
Objective: To add noise in an image.
Program:
clc;
clear all;
close all;
I=imread(‘Image.png’);
I=rgb2gray(I);
SPI=imnoise(I, ‘salt & pepper’0.1);
GI=imnoise(I, ‘gaussian’,0.1,0.05);
SI=imnoise(I, ‘speckle’,0.5);
figure
subplot(221)
imshow(I)
title(‘\bf\fontsize{20} Original Image’)
subplot(222)
imshow(SPI)
title(‘\bf\fontsize{20} Salt and Pepper Noise’)
subplot(223)
imshow(GI)
title(‘\bf\fontsize{20} Gaussian Noise’)
subplot(224)
imshow(SI)
title(‘\bf\fontsize{20} Speckle Noise’)
Output: