You are on page 1of 3

close all

TP3 : correction
clear all
imread('Image1.jpg'); %%function reads the image from the file specified by filename, inferring the format of the file from its con tents.
M1=ans;
subplot(5,3,1); %% function divides the current figure into an m-by-n grid and creates axes in the position specified by p
S1=M1(:,:,1);
imshow(S1);%%function displays the grayscale image I in a figure

imread('Image2.jpg');
M2=ans;
subplot(5,3,2);
S2=M2(:,:,1);
imshow(S2);

imread('Image3.jpg');
M3=ans;
subplot(5,3,3);
S3=M3(:,:,1);
imshow(S3);

I1 = imread('Image1.jpg');
subplot(5,3,4);
imhist(I1)

I2 = imread('Image2.jpg');
subplot(5,3,5);
imhist(I2)

I3 = imread('Image3.jpg');
subplot(5,3,6);
imhist(I3)

BI1=S1;
BI1(S1<100)=0;
BI1(S1>=100)=255;
subplot(5,3,7);
imshow(BI1);

BI2=S2;
BI2(S2<80)=0;
BI2(S2>=160)=255;
BI2((S2>=80) & (S2<160))=120;
subplot(5,3,8);
imshow(BI2);
BI3=S3;
BI3(S3<110)=0;
BI3(S3>=110)=255;
s ubplot(5,3,9); %% function divi des the current figure into an m-by-n gri d and creates axes i n
the position specified by p
i ms how(BI3); %%function displays the grayscale image I in a figure

Ma x=double(max(max(S1))); %%function returns the maximum elements of a n array.


Mi n=double(min(min(S1))); %%function returns the maximum elements of an array.

X1=((double(S1)-Min)/(Max-Mi n))*255; %% double function converts the symbolic value s to


double precision
X1=ui nt8(X1); %%function converts the OPC HDA da ta object array DObj into a uint8 matrix
s ubplot(5,3,10);
i ms how(X1);

Ma x=double(max(max(S2))); %%function returns the maximum elements of a n array.


Mi n=double(min(min(S2))); %%function returns the maximum elements of an array.

X2=((double(S2)-Min)/(Max-Mi n))*255; %% double function converts the symbolic value s to


double precision
X2=ui nt8(X2); %%function converts the OPC HDA da ta object array DObj into a uint8 matrix
s ubplot(5,3,11);
i ms how(X2);

Ma x=double(max(max(S3))); %%function returns the maximum elements of a n array.


Mi n=double(min(min(S3))); %%function returns the maximum elements of an array.

X3=((double(S3)-Min)/(Max-Mi n))*255; %% double function converts the symbolic value s to


double precision
X3=ui nt8(X3); %%function converts the OPC HDA da ta object array DObj into a uint8 matrix
s ubplot(5,3,12);
i ms how(X3);

You might also like