Dip Lab Programs
Dip Lab Programs
figure();
subplot(221);imagesc(I);title('ORIGINAL IMAGE');
subplot(222);imagesc(I,[0,255]);title('ADJUSTED SPATIAl RANGE OF 256');
subplot(223);imagesc(I,[0,127]);title('ADJUSTED SPATIAl RANGE OF 128');
subplot(224);imshow(I,SP);title('AUTOMATIOCALLY ADJUSTED SPATIAl RANGE');
figure();
subplot(321);imagesc(I);title('ORIGINAL IMAGE');
subplot(322);imagesc(IA1);title('INTENSITY RESOLUTION VALUE OF 0.25');
subplot(323);imagesc(IA2);title('INTENSITY RESOLUTION VALUE OF 0.50');
subplot(324);imagesc(IA3);title('INTENSITY RESOLUTION VALUE OF 0.75');
subplot(325);imagesc(IA4);title('INTENSITY RESOLUTION VALUE OF 1');
subplot(326);imagesc(IA);title('AUTOMATICALLY ADJUSTED IMAGE');
N=imcomplement(I);
G1=imadjust(I,[],[],3);
G2=imadjust(I,[],[],1);
G3=imadjust(I,[],[],0.5);
L1=0.1*log(1+double(I));
L2=0.15*log(1+double(I));
L3=0.2*log(1+double(I));
M=mean2(I);
C1=1./(1+(M./(double(I)+eps)).^4);
C2=1./(1+(M./(double(I)+eps)).^5);
C3=1./(1+(M./(double(I)+eps)).^10);
figure();
subplot(121);imshow(I);title('ORIGINAL IMAGE');
subplot(122);imshow(N);title('NEGATIVE IMAGE');
figure();
subplot(221);imshow(I);title('ORIGINAL IMAGE');
subplot(222);imshow(G1);title('GAMMA VALUE 3');
subplot(223);imshow(G2);title('GAMMA VALUE 1');
subplot(224);imshow(G3);title('GAMMA VALUE 0.5');
figure();
subplot(221);imshow(I);title('ORIGINALIMAGE');
subplot(222);imshow(L1);title('SCALING FUNCTION VALUE 0.1'); subplot(223);imshow(L2);title('SCALING
FUNCTION VALUE 0.15'); subplot(224);imshow(L3);title('SCALING FUNCTION VALUE 0.2');
figure();
subplot(221);imshow(I);title('ORIGINAL IMAGE');
subplot(222);imshow(C1);title('SLOPE FUNCTION VALUE 4'); subplot(223);imshow(C2);title('SLOPE FUNCTION
VALUE 5'); subplot(224);imshow(C3);title('SLOPE FUNCTION VALUE 10');
INPUT & OUTPUT:
EXPT.NO: 4 DFT ANALYSIS
S=fft2(S1);
M=abs(S);
P=angle(S);
R=ifft2(S);
[cA,cH,cV,cD]=dwt2(S1,'db1');
RW=idwt2(cA,cH,cV,cD,'db1');
figure();
subplot(221);imshow(S1);title('INPUT IMAGE');
subplot(222);imshow(M);title('MAGNITUDE OF INPUT IMAGE'); subplot(223);imshow(P);title('PHASE ANGLE
OF INPUT IMAGE '); subplot(224);imshow(R);title('RECONSTRUCTION OF INPUT IMAGE ');
figure();
subplot(221);imshow(S1);title('INPUT IMAGE'); subplot(222);imshow(cA);title('APPROXIMATION IMAGE');
subplot(223);imshow(cH);title('HORIZONTAL IMAGE'); subplot(224);imshow(RW);title('RECONSTRUCTION OF
INPUT IMAGE ');
figure();
subplot(221);imagesc(I);title('INPUT IMAGE');
subplot(222);imagesc(C);title('COSINE TRANSFORMED IMAGE');
subplot(223);imagesc(WH);title('WALSH-HADAMARD TRANSFROMED IMAGE');
subplot(224);imagesc(A);title('HAAR TRANSFORMED IMAGE');
figure();
subplot(221);imagesc(I);title('INPUT IMAGE');
subplot(222);imagesc(IC);title('RECONSTRUCTION OF COSINE TRANSFORMED IMAGE');
subplot(223);imagesc(IWH);title('RECONSTRUCTION OF WALSH-HADAMARD TRANSFROMED IMAGE');
subplot(224);imagesc(IH);title('RECONSTRUCTION OF HAAR TRANSFORMED IMAGE');
D=imadjust(I,[],[],3);
B=imadjust(I,[],[],0.1);
HEI=histeq(I);
HED=histeq(D);
HEB=histeq(B);
figure();
subplot(221);imshow(I);title('INPUT IMAGE');
subplot(222);imhist(I);title('HISTOGRAM OF INPUT IMAGE');
subplot(223);imshow(HEI);title('HISTOGRAM EQUALIZED INPUT IMAGE');
subplot(224);imhist(HEI);title('HISTOGRAM OF EQUALIZED IMAGE');
figure();
subplot(221);imshow(D);title('LOW INTENSITY IMAGE');
subplot(222);imhist(D);title('HISTOGRAM OF LOW INTENSITY IMAGE ');
subplot(223);imshow(HED);title('HISTOGRAM EQUALIZED LOW INTENSITY IMAGE');
subplot(224);imhist(HED);title('HISTOGRAM OF EQUALIZED LOW INTENSITY IMAGE');
figure();
subplot(221);imshow(B);title('HIGH INTENSITY IMAGE');
subplot(222);imhist(B);title(' HISTOGRAM OF IMAGE ');
subplot(223);imshow(HEB);title('HISTOGRAM EQUALIZED HIGH INTENSITY IMAGE');
subplot(224);imhist(HEB);title('HISTOGRAM OF EQUALIZED HIGH INTENSITY IMAGE');
M=medfilt2(A);
O=ordfilt2(A,25,true(5));
W=wiener2(A);
H1 = fspecial('gaussian');G=imfilter(A,H1);
H2 = fspecial('log');L=imfilter(A,H2);
M1=medfilt2(B);
O1=ordfilt2(B,25,true(5));
W1=wiener2(B);
H1 = fspecial('gaussian'); G1=imfilter(B,H1);
H2 = fspecial('log'); L1=imfilter(B,H2);
M2=medfilt2(C);
O2=ordfilt2(C,25,true(5));
W2=wiener2(C);
H1 = fspecial('gaussian');G2=imfilter(C,H1);
H2 = fspecial('log');L2=imfilter(C,H2);
M3=medfilt2(D);
O3=ordfilt2(D,25,true(5));
W3=wiener2(D);
H1 = fspecial('gaussian');G3=imfilter(D,H1);
H2 = fspecial('log');L3=imfilter(D,H2);
figure();
subplot(321);imshow(I);title('ORIGINAL IMAGE');
subplot(322);imshow(A);title('ORIGINAL IMAGE WITH SALT & PEPPER NOISE');
subplot(323);imshow(B);title('ORIGINAL IMAGE WITH POISSON NOISE');
subplot(324);imshow(C);title('ORIGINAL IMAGE WITH GAUSSIAN NOISE');
subplot(313);imshow(D);title('ORIGINAL IMAGE WITH SPECKLE NOISE');
figure();
subplot(321);imshow(A);title('ORIGINAL IMAGE WITH SALT & PEPPER NOISE');
subplot(322);imshow(M);title('MEDIAN FILTERED IMAGE'); subplot(323);imshow(O);title('ORDER FILTERED
IMAGE'); subplot(324);imshow(W);title('WIENER FILTERED IMAGE'); subplot(325);imshow(G);title('GAUSSION
FILTERED IMAGE'); subplot(326);imshow(L);title('LAPLACIAN FILTERED IMAGE');
figure();
subplot(321);imshow(B);title('ORIGINAL IMAGE WITH POISSON NOISE');
subplot(322);imshow(M1);title('MEDIAN FILTERED IMAGE'); subplot(323);imshow(O1);title('ORDER FILTERED
IMAGE'); subplot(324);imshow(W1);title('WIENER FILTERED IMAGE');
subplot(325);imshow(G1);title('GAUSSION FILTERED IMAGE'); subplot(326);imshow(L1);title('LAPLACIAN
FILTERED IMAGE');
figure();
subplot(321);imshow(C);title('ORIGINAL IMAGE WITH GAUSSIAN NOISE');
subplot(322);imshow(M2);title('MEDIAN FILTERED IMAGE'); subplot(323);imshow(O2);title('ORDER FILTERED
IMAGE'); subplot(324);imshow(W2);title('WIENER FILTERED IMAGE');
subplot(325);imshow(G2);title('GAUSSION FILTERED IMAGE'); subplot(326);imshow(L2);title('LAPLACIAN
FILTERED IMAGE');
figure();
subplot(321);imshow(D);title('ORIGINAL IMAGE WITH SPECKLE NOISE');
subplot(322);imshow(M3);title('MEDIAN FILTERED IMAGE'); subplot(323);imshow(O3);title('ORDER FILTERED
IMAGE'); subplot(324);imshow(W3);title('WIENER FILTERED IMAGE');
subplot(325);imshow(G3);title('GAUSSION FILTERED IMAGE'); subplot(326);imshow(L3);title('LAPLACIAN
FILTERED IMAGE');
clc;
clear all;
close all;
SE1= strel('line',10,45);
SE2= strel('disk',5);
SE3= strel('square',10);
SE4= strel('diamond',8);
SE5= strel('rectangle',[10 20]);
D1= imdilate(I,SE1);
D2= imdilate(I,SE2);
D3= imdilate(I,SE3);
D4= imdilate(I,SE4);
D5= imdilate(I,SE5);
E1= imerode(I,SE1);
E2= imerode(I,SE2);
E3= imerode(I,SE3);
E4= imerode(I,SE4);
E5= imerode(I,SE5);
ED1= imdilate(E1,SE1);
ED2= imdilate(E2,SE2);
ED3= imdilate(E3,SE3);
ED4= imdilate(E4,SE4);
ED5= imdilate(E5,SE5);
figure();
subplot(321);imshow(I);title('ORIGINAL IMAGE');
subplot(322);imshow(D1);title('IMAGE DILATION USING LINE SHAPE');
subplot(323);imshow(D2);title('IMAGE DILATION USING DISK SHAPE');
subplot(324);imshow(D3);title('IMAGE DILATION USING SQUARE SHAPE');
subplot(325);imshow(D4);title('IMAGE DILATION USING DIAMOND SHAPE');
subplot(326);imshow(D5);title('IMAGE DILATION USING RECTANGULAR SHAPE');
figure();
subplot(321);imshow(I);title('ORIGINAL IMAGE');
subplot(322);imshow(E1);title('IMAGE EROSION USING LINE SHAPE');
subplot(323);imshow(E2);title('IMAGE EROSION USING DISK SHAPE');
subplot(324);imshow(E3);title('IMAGE EROSION USING SQUARE SHAPE');
subplot(325);imshow(E4);title('IMAGE EROSION USING DIAMOND SHAPE');
subplot(326);imshow(E5);title('IMAGE EROSION USING RECTANGULAR SHAPE');
figure();
subplot(321);imshow(I);title('ORIGINAL IMAGE');
subplot(322);imshow(ED1);title('IMAGE EROSION CUM DILATION USING LINE SHAPE');
subplot(323);imshow(ED2);title('IMAGE EROSION CUM DILATION USING DISK SHAPE');
subplot(324);imshow(ED3);title('IMAGE EROSION CUM DILATION SQUARE SHAPE');
subplot(325);imshow(ED4);title('IMAGE EROSION CUM DILATION DIAMOND SHAPE');
subplot(326);imshow(ED5);title('IMAGE EROSION CUM DILATION RECT SHAPE');
clc;
clear all;
close all;
s=edge(I,'sobel');
s1=edge(I,'sobel',0.15);
s2=edge(I,'sobel','horizontal');
s3=edge(I,'sobel','vertical');
s4=edge(I,'sobel','both');
c=edge(I,'canny');
c1=edge(I,'canny',0.15);
c2=edge(I,'canny','horizontal');
c3=edge(I,'canny','vertical');
c4=edge(I,'canny','both');
p=edge(I,'prewitt');
p1=edge(I,'prewitt',0.15);
p2=edge(I,'prewitt','horizontal');
p3=edge(I,'prewitt','vertical');
p4=edge(I,'prewitt','both');
r=edge(I,'roberts');
r1=edge(I,'roberts',0.15);
r2=edge(I,'roberts','horizontal');
r3=edge(I,'roberts','vertical');
r4=edge(I,'roberts','both');
% Prewitt Operator:
l=edge(I,'log');
l1=edge(I,'log',[ ]);
l2=edge(I,'log','horizontal');
l3=edge(I,'log','vertical');
l4=edge(I,'log','both');
figure();
subplot(321);imshow(I);title('GRAY SCALE IMAGE');
subplot(322);imshow(s);title('SIMPLE EDGE DETECTION');
subplot(323);imshow(s1);title('SOBEL WITH THRESHOLD');
subplot(324);imshow(s2);title('SOBEL WITH HORIZONTAL');
subplot(325);imshow(s3);title('SOBEL WITH VERTICAL');
subplot(326);imshow(s4);title('SOBEL WITH BOTH DIRECTION');
figure();
subplot(321);imshow(I);title('GRAY SCALE IMAGE');
subplot(322);imshow(c);title('SIMPLE EDGE DETECTION');
subplot(323);imshow(c1);title('CANNY WITH THRESHOLD');
subplot(324);imshow(c2);title('CANNY WITH HORIZONTAL');
subplot(325);imshow(c3);title('CANNY WITH VERTICAL');
subplot(326);imshow(c4);title('CANNY WITH BOTH DIRECTION');
figure();
subplot(321);imshow(I);title('GRAY SCALE IMAGE');
subplot(322);imshow(p);title('SIMPLE EDGE DETECTION');
subplot(323);imshow(p1);title('PREWITT WITH THRESHOLD');
subplot(324);imshow(p2);title('PREWITT WITH HORIZONTAL');
subplot(325);imshow(p3);title('PREWITT WITH VERTICAL');
subplot(326);imshow(p4);title('PREWITT WITH BOTH DIRECTION');
% Laplacian Operator:
figure();
subplot(321);imshow(I);title('GRAY SCALE IMAGE');
subplot(322);imshow(r);title('SIMPLE EDGE DETECTION');
subplot(323);imshow(r1);title('ROBERTS WITH THRESHOLD');
subplot(324);imshow(r2);title('ROBERTS WITH HORIZONTAL');
subplot(325);imshow(r3);title('ROBERTS WITH VERTICAL');
subplot(326);imshow(r4);title('ROBERTS WITH BOTH DIRECTION');
figure();
subplot(321);imshow(I);title('GRAY SCALE IMAGE');
subplot(322);imshow(l);title('SIMPLE EDGE DETECTION');
subplot(323);imshow(l1);title('LAPLACIAN WITH THRESHOLD');
subplot(324);imshow(l2);title('LAPLACIAN WITH HORIZONTAL');
subplot(325);imshow(l3);title('LAPLACIAN WITH VERTICAL');
subplot(326);imshow(l4);title('LAPLACIAN WITH BOTH DIRECTION');
clc;
clear all;
close all;
B=imbinarize(I);
SI=B.*I;
figure();
subplot(221);imshow(I);title('ORIGINAL IMAGE ');
subplot(222);imshow(B);title('BINARY IMAGE');
subplot(212);imshow(SI);title('ROI FROM THE ORIGINAL IMAGE');
clc;
clear all;
close all;
T=0.5;
S=wthresh(I,'s',T);
H=wthresh(I,'h',T);
figure();
subplot(221);imshow(I);title('ORIGINAL IMAGE ');
subplot(222);imshow(S);title('SOFT THRESHOLDING');
subplot(212);imshow(H);title('HARD THRESHOLDING');
clc;
clear all;
close all;
subplot(2,2,1);imshow(RGB);title('Original Image');
subplot(2,2,2);imshow(R);title('Red Component');
subplot(2,2,3);imshow(G);title('Green Component');
subplot(2,2,4);imshow(B);title('Blue Component');