Вы находитесь на странице: 1из 5

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

PARUL INSTITUTE OF ENGINEERING


PARUL UNIVERSITY

Class : BE-8th SEM Subject : Fundamentals of Image


Processing
Practical No.: 5 Subject Code: 2181102

AIM: Write MATLAB code to perform the bit-plane slicing method on gray
scale image.
OBJECTIVE The objective of this lab is to perform the bit-plane slicing method on gray
: scale image using MATLAB.
TOOLS: MATLAB
THEORY: Commands :

1. bitand :
Bitwise AND.
Syntax
C = bitand(A, B)
Description
C = bitand(A, B) returns the bitwise AND of arguments A and B, where A and B are
unsigned integers or arrays of unsigned integers.
Example
The five-bit binary representations of the integers 13 and 27 are 01101 and 11011,
respectively. Performing a bitwise AND on these numbers yields 01001, or 9:
C = bitand(uint8(13), uint8(27))
C=9
2. bitget :
Bit at specified position
Syntax
C = bitget(A, bit)
Description
C = bitget(A, bit) returns the value of the bit at position bit in A. Operand A must be
an unsigned integer or an array of unsigned integers, and bit must be a number
between 1 and the number of bits in the unsigned integer class of A (e.g., 32 for the
uint32 class).

Example
The dec2bin function converts decimal numbers to binary. However, you can also use the
bitget function to show the binary representation of a decimal number. Just test successive
bits from most to least significant:
disp(dec2bin(13))
1101
C = bitget(uint8(13), 4:-1:1)
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
PARUL INSTITUTE OF ENGINEERING
PARUL UNIVERSITY

C=1 1 0 1

ALGORITHM:

1. Add the path of the image.


2. Read i/p image.
3. Display the image matrix.
4. Display the grayscale matrix.
5. Display the each bit of the image.
6. Reconstruct the image by adding the bits.
7. Display the all o/p image.
8. Give title to each image.

MATLAB CODE:
clc;
clear all;
close all;
addpath('C:\Users\Saisaran\Pictures');
j=imread('PENGU.jpg');
i=rgb2gray(j);
i1=bitand(i,0);
figure(1);
subplot(2,4,1);
imshow(i1);
title('bitand image 1');
i2=bitand(i,2);
figure(1);
subplot(2,4,2);
imshow(i2);
title('bitand image 2');
i3=bitand(i,4);
subplot(2,4,3);
imshow(i3);
title('bitand image 3');
i4=bitand(i,8);
subplot(2,4,4);
imshow(i4);
title('bitand image 4');
i5=bitand(i,16);
subplot(2,4,5);
imshow(i5);
title('bitand image 5');
i6=bitand(i,32);
subplot(2,4,6);
imshow(i6);
title('bitand image 6');
i7=bitand(i,64);
subplot(2,4,7);
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
PARUL INSTITUTE OF ENGINEERING
PARUL UNIVERSITY

imshow(i7);
title('bitand image 7');
i8=bitand(i,128);
subplot(2,4,8);
imshow(i8);
title('bitand image 8');
a=i6+i7+i8;
figure(2);
subplot(1,2,1);
imshow(i);
title('original image 1');
subplot(1,2,2);
imshow(a);
title('bitand reconstructed image');
addpath('C:\Users\Saisaran\Pictures');
k=imread('TULIPS.jpg');
I=rgb2gray(k);
I1=bitget(I,1);
figure(3);
subplot(2,4,1);
imshow(logical(I1));
title('bitget image 1');
I2=bitget(I,2);
subplot(2,4,2);
imshow(logical(I2));
title('bitget image 2');
I3=bitget(I,3);
subplot(2,4,3);
imshow(logical(I3));
title('bitget image 3');
I4=bitget(I,4);
subplot(2,4,4);
imshow(logical(I4));
title('bitget image 4');
I5=bitget(I,5);
subplot(2,4,5);
imshow(logical(I5));
title('bitget image 5');
I6=bitget(I,6);
subplot(2,4,6);
imshow(logical(I6));
title('bitget image 6');
I7=bitget(I,7);
subplot(2,4,7);
imshow(logical(I7));
title('bitget image 7');
I8=bitget(I,8);
subplot(2,4,8);
imshow(logical(I8));
title('bitget image 8');
b=(I6.*32)+(I7.*64)+(I8.*128);
figure(4);
subplot(1,2,1);
imshow(I);
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
PARUL INSTITUTE OF ENGINEERING
PARUL UNIVERSITY

title('original image 2');


subplot(1,2,2);
imshow(b);
title('bitget reconstructed image');

RESULT:
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
PARUL INSTITUTE OF ENGINEERING
PARUL UNIVERSITY

CONCLUSION:

Вам также может понравиться