Bit Plane Slicing in Matlab etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Bit Plane Slicing in Matlab etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

28 Mart 2016 Pazartesi

Bit Plane Slicing in Matlab

bit plane of a digital discrete signal (such as image or sound) is a set of bits corresponding to a given bit position in each of the binary numbers representing the signal.[1]
For example, for 16-bit data representation there are 16 bit planes: the first bit plane contains the set of the most significant bit, and the 16th contains the least significant bit.
It is possible to see that the first bit plane gives the roughest but the most critical approximation of values of a medium, and the higher the number of the bit plane, the less is its contribution to the final stage. Thus, adding a bit plane gives a better approximation.
If a bit on the nth bit plane on an m-bit dataset is set to 1, it contributes a value of 2(m-n), otherwise it contributes nothing. Therefore, bit planes can contribute half of the value of the previous bit plane. For example, in the 8-bit 10110101 (181 in decimal) the bit planes work as follows:


Bitplane is sometimes used as synonymous to Bitmap; however, technically the former refers to the location of the data in memory and the latter to the data itself.[2]
One aspect of using bit-planes is determining whether a bit-plane is random noise or contains significant information.
One method for calculating this is compare each pixel (X,Y) to three adjacent pixels (X-1,Y), (X,Y-1) and (X-1,Y-1). If the pixel is the same as at least two of the three adjacent pixels, it is not noise. A noisy bit-plane will have 49% to 51% pixels that are noise.[3]

Applications[edit]

As an example, in PCM sound encoding the first bit in the sample denotes the sign of the function, or in other words defines the half of the whole amplitude values range, and the last bit defines the precise value. Replacement of more significant bits result in more distortion than replacement of less significant bits. In lossy media compression that uses bit-planes it gives more freedom to encode less significant bit-planes and it is more critical to preserve the more significant ones.[4]
As illustrated in the image above, the early bitplanes, particularly the first, may have constant runs of bits, and thus can be efficiently encoded by run-length encoding. This is done (in the transform domain) in the Progressive Graphics File image format, for instance.
Some computers displayed graphics in bitplane format most notably the Amiga and Atari ST, contrasting with the more common packed format.

Programs[edit]

Many image processing packages can split an image into bit-planes. Open source tools such as Pamarith from Netpbm and Convert from ImageMagick can be used to generate bit-planes.




im=imread('SpaceElevator.jpg');      % imaj dosyasını okuma 
figure(7);imshow(im);                      % imaj dosyasının gösterimi 

I1 = rgb2gray(im);                            % resmi grayscale versiyona cevirme 
figure(8);imshow(I1); 

B1=bitget(I1,1); 
B1=B1*1;figure(9), imshow(logical(B1));title('Bit plane 1'); 
B2=bitget(I1,2); 
B2=B2*2;figure(10), imshow(logical(B2));title('Bit plane 2'); 
B3=bitget(I1,3); 
B3=B3*4;figure(11), imshow(logical(B3));title('Bit plane 3'); 
B4=bitget(I1,4); 
B4=B4*8;figure(12), imshow(logical(B4));title('Bit plane 4'); 
B5=bitget(I1,5); 
B5=B5*16;figure(13), imshow(logical(B5));title('Bit plane 5'); 
B6=bitget(I1,6); 
B6=B6*32;figure(14), imshow(logical(B6));title('Bit plane 6'); 
B7=bitget(I1,7); 
B7=B7*64; figure(15), imshow(logical(B7));title('Bit plane 7'); 
B8=bitget(I1,8); 
B8=B8*128; figure(16), imshow(logical(B8));title('Bit plane 8'); 

We can hide some knowledge into the slices and than when we reconstruct the image 
After reconstruction there won't be any effect of this knowledge. It is unvisible. In our 
example we are going to add our name into the least significant bit slice in binary form.
In order to do it firstly we should change our name into binary format. Search it online,
I found a website that converts any text you write into binary format. After that we will
just import our binary name bit by bit where ever we want.

% My name in binary format 
%|K|O|R|A|Y| |K|A|R|A|<new line> 
%|75|79|82|65|89|32|75|65|82|65|13 
%|4B|4F|52|41|59|20|4B|41|52|41|0D 
%|01001011|01001111|01010010|01000001|01011001|00100000|01001011 
%|01000001|01010010|01000001|00001101 

% Adding the name to the lowest bit plane in binary form
% May be there is another easy way to do it but for now it works. 

A1(1)=0;A1(2)=1;A1(3)=0;A1(4)=0;A1(5)=1;A1(6)=0;A1(7)=1;A1(8)=1; 
A1(9)=0;A1(10)=1;A1(11)=0;A1(12)=0;A1(13)=1;A1(14)=1;A1(15)=1;A1(16)=1; 
A1(17)=0;A1(18)=1;A1(19)=0;A1(20)=1;A1(21)=0;A1(22)=0;A1(23)=1;A1(24)=0; 
A1(25)=0;A1(26)=1;A1(27)=0;A1(28)=0;A1(29)=0;A1(30)=0;A1(31)=0;A1(32)=1; 
A1(33)=0;A1(34)=1;A1(35)=0;A1(36)=1;A1(37)=1;A1(38)=0;A1(39)=0;A1(40)=1; 
A1(41)=0;A1(42)=0;A1(43)=1;A1(44)=0;A1(45)=0;A1(46)=0;A1(47)=0;A1(48)=0; 
A1(49)=0;A1(50)=1;A1(51)=0;A1(52)=0;A1(53)=1;A1(54)=0;A1(55)=1;A1(56)=1; 
A1(57)=0;A1(58)=1;A1(59)=0;A1(60)=0;A1(61)=0;A1(62)=0;A1(63)=0;A1(64)=1; 
A1(65)=0;A1(66)=1;A1(67)=0;A1(68)=1;A1(69)=0;A1(70)=0;A1(71)=1;A1(72)=0; 
A1(73)=0;A1(74)=1;A1(75)=0;A1(76)=0;A1(77)=0;A1(78)=0;A1(79)=0;A1(80)=1; 
A1(81)=0;A1(82)=0;A1(83)=0;A1(84)=0;A1(85)=1;A1(86)=1;A1(87)=0;A1(88)=1; 

% Reconstruction of the image again step by step 

A1=B1; 
A2=B1+B2; 
A3=B1+B2+B3; 
A4=B1+B2+B3+B4; 
A5=B1+B2+B3+B4+B5; 
A6=B1+B2+B3+B4+B5+B6; 
A7=B1+B2+B3+B4+B5+B6+B7; 
A8=B1+B2+B3+B4+B5+B6+B7+B8; 

figure(17), imshow((A1));title('STEP1'); 
figure(18), imshow((A2));title('STEP2'); 
figure(19), imshow((A3));title('STEP3'); 
figure(20), imshow((A4));title('STEP4'); 
figure(21), imshow((A5));title('STEP5'); 
figure(22), imshow((A6));title('STEP6'); 
figure(23), imshow((A7));title('STEP7'); 
figure(24), imshow((A8));title('STEP8'); 



JAVA DIARY - 2

Class kodlarının içersinde ana fonksiyonumuzu public static void main olarak tanımlıyoruz. Parantezler içersinde görüldüğü gibi String[] ar...