Uploaded by Smita Sutar

MATLAB Assignment 2

advertisement
%MATLAB Assignment 2
clear all
close all
clc
% Read & Display image
I= rgb2gray(imread('task1.jpg'));
figure, imshow(I), title('Original Image'), colorbar
figure, imagesc(I), title('Scaled Image'), colorbar
% Find trace intensities min & max using tool tip in figure
ETmin = 105
ETmax = 150
% Loop over pixels make traces white nd background black
[row, col] = size(I)
Ibinary = zeros(row,col); % black image
for i= 1:row %loop over all rows
for j= 1:col % loop over column
if (ETmax > I(i,j)&& I(i,j)> ETmin) % trace pixel
Ibinary(i,j) = 255; % set level to white
end
end
end
figure, imshow(Ibinary), title('Binary Image of Traces')
colorbar
%histogram equilization
figure
subplot(2,2,1), imshow(I),title('Original Image')
subplot(2,2,2), imhist(I),title('Histogram of original Image')
I2 = histeq(I); % enhanced histogram
subplot(2,2,3), imshow(I2),title('Enhanced Image')
subplot(2,2,4), imhist(I2),title('Histogram Enhanced Image')
% Gamma Correction
% Loop over pixels make traces white nd background black
[row, col] = size(I);
Igamma1 = I; %caste double from uint0
Igamma2 = I;
for i= 1:row %loop over all rows
for j= 1:col % loop over column
Igamma1(i,j) = double(I(i,j))^0.9;
Igamma2(i,j) = double(I(i,j))^1.0;
end
end
figure,
subplot(3,1,1), imshow(I),title('Original Image')
subplot(3,1,2), imshow(Igamma1),title('Gamma = 0.9')
subplot(3,1,3), imshow(Igamma2),title('Gamma = 1.0')
Download