0% found this document useful (0 votes)
187 views

Digital Image Processing Lab - 1

This laboratory experiment explores point-to-point transformations and histogram equalization on digital images. It performs thresholding, logarithmic transformation, power law transformation, and contrast stretching on the "cameraman.tif" test image. Histogram equalization is also demonstrated on the "pout.tif" image where the image and its histogram are shown before and after equalization.

Uploaded by

Ishaan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views

Digital Image Processing Lab - 1

This laboratory experiment explores point-to-point transformations and histogram equalization on digital images. It performs thresholding, logarithmic transformation, power law transformation, and contrast stretching on the "cameraman.tif" test image. Histogram equalization is also demonstrated on the "pout.tif" image where the image and its histogram are shown before and after equalization.

Uploaded by

Ishaan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

6CS4-21: Digital Image Processing Lab

Experiments 1: Point-to-point transformation. This laboratory experiment provides for


thresholding an image and the evaluation of its histogram. Histogram equalization. This
experiment illustrates the relationship among the intensities (gray levels) of an image and its
histogram.

clear all
clc
close all

% Step:1.1 Read the Input image


a=imread('cameraman.tif','tif'); % add path F:\BKBIET\CSE syllbus\dip\lb\Img.jpg','jpg');
a=double(a);
% figure(1); imagesc(a); axis equal; colormap gray; axis off;
I= imresize(a,[256 256]);
figure, imshow(I/255), title('Input image');
figure,imagesc(I),title('Input image'), colormap(gray);

%%apply thersholding operation


I1 = I>140;

subplot(1,2,1);imshow(I/255),title('Input image before thresholding')


subplot(1,2,2); imshow(I1), title('Input image after thresholding')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc, clear all
close all

% Read the Input image


a=imread('cameraman.tif','tif');
[m, n]= size(a) %% image size
%% S = c*log(1+I) take c =1 ; %% use logarithm transformation
I2 = im2double(a);
c=2;
for i= 1:m
for j = 1:n
S(i,j)= c*log(1+I2(i,j));
end
end
subplot(1,2,1); imshow(a), title('Input image before log') %% Check reults
subplot(1,2,2); imshow(S), title('Input image after log transformation') ;
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 3. power law or Gamma transfromation

clc
close all
close all

% Step:1.1 Read the Input image


a=imread('cameraman.tif','tif');
%% image size check
[m, n]= size(a)
%% S = c*I^y) take y = 1, 2,.67,.40,.20 ; %% check results by varying y factor
I2 = im2double(a);
c=2;
for i= 1:m
for j = 1:n
S(i,j)= c*I2(i,j)^3;
end
end
subplot(1,2,1);imshow(I2),title('Input image before power law');
subplot(1,2,2); imshow(S), title('Input image after power law');

%%%%Histogram
close all, clc, clear all
% Step:1.1 Read the Input image
a=imread('pout.tif','tif');
a1=imadjust(a,[0.3, 0.6],[0.0,1.0]); %%Contrast streched operation
figure,
subplot(1,2,1);imshow(a),title('Input image before contrast stretching');
subplot(1,2,2);imshow(a1),title('Input image after contrast stretching');

%%I2= imhist(a1);
S= histeq(a);
figure,
subplot(2,2,1);imshow(a),title('Histogram of Input image');
subplot(2,2,2);imhist(a)
subplot(2,2,3); imshow(S), title('Histogram Equalization');
subplot(2,2,4);imhist(S)

Results

You might also like