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

Matlab Code

This document loads three images (a cameraman photo, a tire, and a shadow), resizes them to a uniform width, and then applies three contrast adjustment techniques (imadjust, histeq, adapthisteq) to each image. It displays the original and adjusted versions of the cameraman and tire photos. For the shadow image, it first converts to LAB colorspace, scales the luminosity layer, applies the adjustments, and converts back to RGB for display. Plots of the image histograms are also produced.

Uploaded by

Dev M Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Matlab Code

This document loads three images (a cameraman photo, a tire, and a shadow), resizes them to a uniform width, and then applies three contrast adjustment techniques (imadjust, histeq, adapthisteq) to each image. It displays the original and adjusted versions of the cameraman and tire photos. For the shadow image, it first converts to LAB colorspace, scales the luminosity layer, applies the adjustments, and converts back to RGB for display. Plots of the image histograms are also produced.

Uploaded by

Dev M Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

clc; close all;

clear all;
cameraman = imread('C:\Users\Administrator\Desktop\Images\concordorthophoto.png');
tire = imread('tire.tif');
[X map] = imread('shadow.tif');
shadow = ind2rgb(X,map); % convert to truecolor
width = 210;
images = {cameraman, tire, shadow};

for k = 1:3
dim = size(images{k});
images{k} = imresize(images{k},[width*dim(1)/dim(2) width],'bicubic');
end

cameraman = images{1};
tire = images{2};
shadow = images{3};
cameraman_imadjust = imadjust(cameraman);
cameraman_histeq = histeq(cameraman);
cameraman_adapthisteq = adapthisteq(cameraman);

imshow(cameraman);
title('Original');

figure, imshow(cameraman_imadjust);
title('Imadjust')
figure, imshow(cameraman_histeq);
title('Histeq');

figure, imshow(cameraman_adapthisteq);
title('Adapthisteq');
tire_imadjust = imadjust(tire);
tire_histeq = histeq(tire);
tire_adapthisteq = adapthisteq(tire);

figure, imshow(tire);
title('Original');

figure, imshow(tire_imadjust);
title('Imadjust');
figure, imshow(tire_histeq);
title('Histeq');

figure, imshow(tire_adapthisteq);
title('Adapthisteq');
figure, imhist(cameraman), title('cameraman.tif');
figure, imhist(tire), title('tire.tif');
srgb2lab = makecform('srgb2lab');
lab2srgb = makecform('lab2srgb');

shadow_lab = applycform(shadow, srgb2lab); % convert to L*a*b*

% the values of luminosity can span a range from 0 to 100; scale them
% to [0 1] range (appropriate for MATLAB(R) intensity images of class double)
% before applying the three contrast enhancement techniques
max_luminosity = 100;
L = shadow_lab(:,:,1)/max_luminosity;

% replace the luminosity layer with the processed data and then convert
% the image back to the RGB colorspace
shadow_imadjust = shadow_lab;
shadow_imadjust(:,:,1) = imadjust(L)*max_luminosity;
shadow_imadjust = applycform(shadow_imadjust, lab2srgb);
shadow_histeq = shadow_lab;
shadow_histeq(:,:,1) = histeq(L)*max_luminosity;
shadow_histeq = applycform(shadow_histeq, lab2srgb);

shadow_adapthisteq = shadow_lab;
shadow_adapthisteq(:,:,1) = adapthisteq(L)*max_luminosity;
shadow_adapthisteq = applycform(shadow_adapthisteq, lab2srgb);

figure, imshow(shadow);
title('Original');

figure, imshow(shadow_imadjust);
title('Imadjust');

You might also like