Skip to content

BIT PLANE SLICING

% **** BIT PLANE SLICING ****
a=imread(‘Moon.tif’);
b=double(a);
[row col]=size(b);
%r=input(‘enter bitval :  ‘);
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(1);
        w1(x,y)=double(d);
        if w1(x,y)==49
            w1(x,y)=255;
        else w1(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(2);
        w2(x,y)=double(d);
        if w2(x,y)==49
            w2(x,y)=255;
        else w2(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(3);
        w3(x,y)=double(d);
        if w3(x,y)==49
            w3(x,y)=255;
        else w3(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(4);
        w4(x,y)=double(d);
        if w4(x,y)==49
            w4(x,y)=255;
        else w4(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(5);
        w5(x,y)=double(d);
        if w5(x,y)==49
            w5(x,y)=255;
        else w5(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(6);
        w6(x,y)=double(d);
        if w6(x,y)==49
            w6(x,y)=255;
        else w6(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(7);
        w7(x,y)=double(d);
        if w7(x,y)==49
            w7(x,y)=255;
        else w7(x,y)=0;
        end
    end
end
for x=1:row
    for y=1:col
        c=dec2bin(b(x,y),8);
        d=c(8);
        w8(x,y)=double(d);
        if w8(x,y)==49
            w8(x,y)=255;
        else w8(x,y)=0;
        end
    end
end
subplot(3,3,1);
imshow(uint8(w1));
subplot(3,3,2);
imshow(uint8(w2));
subplot(3,3,3);
imshow(uint8(w3));
subplot(3,3,4);
imshow(uint8(w4));
subplot(3,3,5);
imshow(uint8(w5));
subplot(3,3,6);
imshow(uint8(w6));
subplot(3,3,7);
imshow(uint8(w7));
subplot(3,3,8);
imshow(uint8(w8));
subplot(3,3,9);

imshow(a);


Output
Bit Plane Slicing Output
Bit Plane Slicing

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!