Showing posts with label Gray Level Slicing in matlab. Show all posts
Showing posts with label Gray Level Slicing in matlab. Show all posts

Monday, March 28, 2016

Bit Plane Slicing in MATLAB

       Read fractal.jpg file. Display individual bits as binary image. Display and comment on the result.  (Hint: use bitget built-in function)

CODE:

clc; clear;

A=imread('fractal.jpg');
[row,col]=size(A);
subplot(3,3,1), imshow(A), title('Original Image');
C=zeros(row,col,8);
for k=1:8
    for i=1:row
        for j=1:col
            C(i,j,k)=bitget(A(i,j),k);        %Bit slicing
        end
    end
    subplot(3,3,k+1), imshow(C(:,:,k)), title(['Bit Plane ',num2str(k-1)]);
end


OUTPUT RESULT :

We observe that the three higher order planes, especially the 8th bit plane, contain a significant amount of the visually significant data. The lower order planes contribute to more subtle intensity details in the image. Decomposing an image into its bit planes is useful for analyzing the relative importance of each bit in the image and is useful for image compression.

Sunday, March 27, 2016

Gray Level Slicing in MATLAB

 Gray Level Slicing: High-light specific range of gray values without background and with background.

       Read kidney.tif file. Enter lower and upper threshold value from the user. Apply gray level slicing with and without background. Display the result.

 CODE:
clc; clear all;

i=imread('kidney.tif');          % should be graylevel image
j=double(i);
k=double(i);
[row,col]=size(j);
T1=input('Enter the Lowest threshold value:');
T2=input('Enter the Highest threshold value:');
for x=1:row            
    for y=1:col        
        if((j(x,y)>T1) && (j(x,y)<T2))
            j(x,y)=i(x,y);
            k(x,y)=255;
        else
            j(x,y)=0;
            k(x,y)=0;
        end
    end
end

subplot(311), imshow(i), title('Original image')   
subplot(312), imshow(uint8(j)), title('Graylevel slicing with background')
subplot(313), imshow(uint8(k)), title('Graylevel slicing without background')

OUTPUT RESULT: