merging 8 bit planes into single plane by combining the values of each bit into 8-bit value for each pixel
Show older comments
I have two separate 8 bit planes(Images) and I want to align the value of each bit into a 8bit pixel value.for example I have '1' '0' '1' '0' '1' ' 0' '1' '0' as first values of each bit planes and these values should be aligned as 10101010 in one plane as its value of its first pixel.what function to be used to combine these 8 images to form single images with above condition.
5 Comments
James Tursa
on 12 Feb 2019
Please tell us how the data is currently stored (variable type, size, etc).
dileep reddy
on 12 Feb 2019
8 bit planes are images of size 256×256 and in binary form
Guillaume
on 12 Feb 2019
Matlab does not have a binary type. What is binary form as a real matlab type?
What is
class(yourbinarydata)
?
DILEEP REDDY
on 13 Feb 2019
Guillaume
on 13 Feb 2019
Dileep reddy's code and comments moved here:
% clearing the output screen
clc;
% reading image's pixel in c
c = imread('apple.tif');
adjustc=imresize(c,[256,256]);
% storing image information in cd
cd = double(adjustc);
% extracting all bit one by one
% from 1st to 8th in variable
% from c1 to c8 respectively
c1 = mod(cd, 2);
c2 = mod(floor(cd/2), 2);
c3 = mod(floor(cd/4), 2);
c4 = mod(floor(cd/8), 2);
c5 = mod(floor(cd/16), 2);
c6 = mod(floor(cd/32), 2);
c7 = mod(floor(cd/64), 2);
c8 = mod(floor(cd/128), 2);
% combining image again to form equivalent to original grayscale image
cc = (2 * (2 * (2 * (2 * (2 * (2 * (2 * c8 + c7) + c6) + c5) + c4) + c3) + c2) + c1);
figure;
subplot(2, 5, 1);
imshow(adjustc);
title('Original Image');
% plotting binary image having extracted bit from 1st to 8th
% in subplot from 2nd to 9th
subplot(2,5,2);
%disp(c1);
% plotting original image in first subplot
imshow(c1);
title('bit plane 1');
subplot(2,5,3);
%disp(c2);
imshow(c2);
title('bit plane 2');
subplot(2,5,4);
%disp(c3);
imshow(c3);
title('bit plane 3');
subplot(2,5,5);
%disp(c4);
imshow(c4);
title('bit plane 4');
subplot(2,5,6);
%disp(c5);
imshow(c5);
title('bit plane 5');
subplot(2,5,7);
%disp(c6);
imshow(c6);
title('bit plane 6');
subplot(2,5,8);
%disp(c7);
imshow(c7);
title('bit plane 7');
subplot(2,5,9);
%disp(c8);
imshow(c8);
title('bit plane 8');
% plotting recombined image in 10th subplot
subplot(2, 5, 10);
imshow(uint8(cc));
title('Recombined Image');
I= imread('cameraman.tif');
X1 = edge(I,'canny',0.075);
X2 = edge(I,'canny',0.085);
X3 = edge(I,'canny',0.095);
X4 = edge(I,'canny',0.105);
X5 = edge(I,'canny',0.115);
X6 = edge(I,'canny',0.125);
X7 = edge(I,'canny',0.150);
X8 = edge(I,'canny',0.175);
figure;
subplot(2, 5, 1);
imshow(I);
title('Original Image');
subplot(2, 5, 2);
%disp(BX1);
imshow(X1);
title('Edge map 1');
subplot(2, 5, 3);
%disp(BX2);
imshow(X2);
title('Edge map 2');
subplot(2, 5, 4);
%disp(BX3);
imshow(X3);
title('Edge msp 3');
subplot(2, 5, 5);
%disp(BX4);
imshow(X4);
title('Edge map 4');
subplot(2, 5, 6);
%disp(BX5);
imshow(X5);
title('Edge map 5');
subplot(2, 5, 7);
%disp(BX6);
imshow(X6);
title('Edge map 6');
subplot(2, 5, 8);
%disp(BX7);
imshow(X7);
title('Edge map 7');
subplot(2, 5,9);
%disp(X8);
imshow(X8);
title('Edge map 8');
%xor operation for both the bit decompsed images and edge maps for all the
%8 bit planes
result1xor=bitxor(c1,X1);
result2xor=bitxor(c2,X2);
result3xor=bitxor(c3,X3);
result4xor=bitxor(c4,X4);
result5xor=bitxor(c5,X5);
result6xor=bitxor(c6,X6);
result7xor=bitxor(c7,X7);
result8xor=bitxor(c8,X8);
figure;
subplot(4,2,1);
imshow(result1xor);
%disp(result1xor);
title('1st bit Xor Image');
subplot(4,2,2);
imshow(result2xor);
%disp(result2xor);
title('2nd bitplane Xor ');
subplot(4,2,3);
imshow(result3xor);
%disp(result3xor);
title('3rd bitplane Xor ');
subplot(4,2,4);
imshow(result4xor);
%disp(result4xor);
title('4th bitplane Xor ');
subplot(4,2,5);
imshow(result5xor);
%disp(result5xor);
title('5th bitplane Xor ');
subplot(4,2,6);
imshow(result6xor);
%disp(result6xor);
title('6th bitplane Xor ');
subplot(4,2,7);
imshow(result7xor);
%disp(result7xor);
title('7th bitplane Xor ');
subplot(4,2,8);
imshow(result8xor);
disp(result8xor);
title('8th bitplane Xor ');
q1 = result1xor;
q2 = result2xor;
q3 = result3xor;
q4 = result4xor;
q5 = result5xor;
q6 = result6xor;
q7 = result7xor;
q8 = result8xor;
This is my code .At last I want to combine q1,q2...q8 into one image with the previous condition mentioned.
If i use imfuse() function for will it satisfy above condition
Accepted Answer
More Answers (1)
Walter Roberson
on 12 Feb 2019
0 votes
Since your data appears to be char, then permute it so that all of the bits for a pixel are across the rows, and then use bin2dec(), followed by reshape() into the appropriate array size.
2 Comments
DILEEP REDDY
on 12 Feb 2019
James Tursa
on 12 Feb 2019
Can you please help us out and show us the actual variable class and sizes involved, and show us the current code you are using?
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
