Hi Surya,
Bit plane slicing involves decomposition of an image into its constituent bit planes which represent the bits of each pixel value. Standard 8-bit images have 8 bit per pixels and this results in 8 bit planes.
However, it is possible to decompose an image into 16 planes if the image has a higher bit depth, such as 16 bits per pixel.
Here is a sample code for decomposing an image into 16 bit planes:
it = imread('sample_16bit_image.png'); % read the image
% Assuming the image is stored in a 16-bit format
itemp = it(:,:,1);
[r, c] = size(itemp); % get the dimensions of image
s = zeros(r, c, 16); % pre allocate a variable to store 16 bit planes of the image
for k = 1:16
for i = 1:r
for j = 1:c
s(i, j, k) = bitget(itemp(i, j), k); % get kth bit from each pixel
end
end
end
figure, imshow(uint16(itemp)); title('Original Image'); % display original image
figure; % display all the 16 bit planes
% Adjust the subplot layout to accommodate 16 planes
for k = 1:16
subplot(4, 4, k);
imshow(s(:,:,17-k)); % Display from MSB to LSB
title(sprintf('%d Plane', 17-k));
end
% Reconstruct the original image from generated bit planes
rec = zeros(r, c);
for k = 1:16
rec = rec + s(:,:,k) * 2^(k-1);
end
figure, imshow(uint16(itemp)); title('Recovered Image'); % display the reconstructed image
The code is inspired from the "Bit-Plane Slicing" by Akshay Bhosale.