Basic Image Import
Basic Image Import
I2 = histeq(I);
figure
imshow(I2)
figure
imhist(I2)
The Programming concepts is not included in Digital Image Processing Syllabus for ECE
students.
In order to get practical exposure of reading, writing, storing, importing of Image ,Matlab
commands explained to students.
figure
subplot(1,2,1)
imhist(pout)
title("Histogram of pout.tif")
subplot(1,2,2)
imhist(tire)
title("Histogram of tire.tif");
shadow_histeq = shadow_lab;
shadow_histeq(:,:,1) = histeq(L)*max_luminosity;
shadow_histeq = lab2rgb(shadow_histeq);
shadow_adapthisteq = shadow_lab;
shadow_adapthisteq(:,:,1) = adapthisteq(L)*max_luminosity;
shadow_adapthisteq = lab2rgb(shadow_adapthisteq);
Display the original image and the three contrast adjusted images as a montage.
figure
montage({shadow,shadow_imadjust,shadow_histeq,shadow_adapthisteq},"Size",[1
4])
title("Original Image and Enhanced Images using " + ...
"imadjust, histeq, and adapthisteq")
figure
imshow(Iblur1)
title('Smoothed image, \sigma = 2')
figure
imshow(Iblur2)
title('Smoothed image, \sigma = 4')
figure
imshow(Iblur3)
title('Smoothed image, \sigma = 8')
Filter the image with anisotropic Gaussian smoothing kernels. imgaussfilt allows the
Gaussian kernel to have different standard deviations along row and column dimensions.
These are called axis-aligned anisotropic Gaussian filters. Specify a 2-element vector
for sigma when using anisotropic filters.
IblurX1 = imgaussfilt(I,[4 1]);
IblurX2 = imgaussfilt(I,[8 1]);
IblurY1 = imgaussfilt(I,[1 4]);
IblurY2 = imgaussfilt(I,[1 8]);
Display the filtered images.
figure
imshow(IblurX1)
title('Smoothed image, \sigma_x = 4, \sigma_y = 1')
figure
imshow(IblurX2)
title('Smoothed image, \sigma_x = 8, \sigma_y = 1')
figure
imshow(IblurY1)
title('Smoothed image, \sigma_x = 1, \sigma_y = 4')
figure
imshow(IblurY2)
title('Smoothed image, \sigma_x = 1, \sigma_y = 8')
Suppress the horizontal bands visible in the sky region of the original image. Anisotropic
Gaussian filters can suppress horizontal or vertical features in an image. Extract a section
of the sky region of the image and use a Gaussian filter with higher standard deviation
along the X axis (direction of increasing columns).
I_sky = imadjust(I(20:50,10:70));
IblurX1_sky = imadjust(IblurX1(20:50,10:70));
Display the original patch of sky with the filtered version.
figure
imshow(I_sky), title('Sky in original image')
figure
imshow(IblurX1_sky), title('Sky in filtered image')
clc;
clear all;
I = imread('cameraman.tif');
I1=I;
[row coln]= size(I);
I= double(I);
%---------------------------------------------------------
% Subtracting each image pixel value by 128
%--------------------------------------------------------
I = I - (128*ones(256));
quality = input('What quality of compression you require - ');
%----------------------------------------------------------
% Quality Matrix Formulation
%----------------------------------------------------------
Q50 = [ 16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99];
if quality > 50
QX = round(Q50.*(ones(8)*((100-quality)/50)));
QX = uint8(QX);
elseif quality < 50
QX = round(Q50.*(ones(8)*(50/quality)));
QX = uint8(QX);
elseif quality == 50
QX = Q50;
end