You are on page 1of 9

Programming fundamentals

Lab Number Lab 3


Lab Title Image Enhancement in the Spatial Domain
o Bit plane Slicing
o Histograms of digital images and histogram manipulation
o Histogram equalization Single Dimension Arrays

Date: 17-03-2021

Name: Muhammad Sheraz


Semester & Section: 8-A
Codes & Output:

%Task 1

%1st Method

%4th bit

ff=imread('self.jpeg');

fff=rgb2gray(ff);

subplot(221)

imshow(ff)

subplot(222)

imshow(fff)

a=bitget(fff,4);

subplot(223)

imshow(logical(a))
%2nd method

ff=imread('self.jpeg');

fff=rgb2gray(ff);

imshow(ff)

[m,n]=size(fff);

b=double(fff);

c=de2bi(b);

c0=c(:,8);r0=reshape(c0,m,n);

c1=c(:,7);r1=reshape(c1,m,n);

c2=c(:,6);r2=reshape(c2,m,n);

c3=c(:,5);r3=reshape(c3,m,n);

c4=c(:,4);r4=reshape(c4,m,n);

c5=c(:,3);r5=reshape(c5,m,n);

c6=c(:,2);r6=reshape(c6,m,n);

c7=c(:,1);r7=reshape(c7,m,n);

subplot(241);imshow(r0);title('MSB');

subplot(242);imshow(r1);title('7th bit');

subplot(243);imshow(r2);title('6th bit');

subplot(244);imshow(r3);title('5th bit');

subplot(245);imshow(r4);title('4th bit');

subplot(246);imshow(r5);title('3th bit');

subplot(247);imshow(r6);title('2th bit');

subplot(248);imshow(r7);title('LSB');
%Task 2

ff=imread('self.jpeg');

fff=rgb2gray(ff);

imshow(fff)

figure;

imhist(fff)
%Task 3

ff=imread('profile.png');

a=rgb2gray(ff);

figure;

subplot(121);imshow(a);

subplot(122);imhist(a);

fff=imadjust(a,[0.5,0.8],[0.0,1.0]);

ffff=histeq(a);

figure;

subplot(221)

imshow(fff);
title('Strecthed');

subplot(222)

imhist(fff);

title('Histogram');

subplot(223)

imshow(ffff);

title('Eq');

subplot(224)

imhist(ffff);

title('Histogram');
Conclusion:

You might also like