# (6) Bit plane layering (bit Plane slicing)

Source: Internet
Author: User

It is important to know the English translation of the terminology, because Baidu's high-quality posts and articles are less than Google searches.

For grayscale graphs, a pixel is made up of 8 bits. instead of highlighting the grayscale range, we can highlight specific bits to contribute to the overall appearance of the image (it is important to understand that) a 8-bit grayscale chart can consider layering 1 to 8 bit planes. It is easy to understand that 4 Gauchebutte planes, especially the last two bit planes, contain most of the data that is visually important. The lower-order bit planes contribute finer grayscale detail to the image.

Bit plane layering is the most important of its layered algorithm, the algorithm is based on the upper part of the boldface word, highlighting the level of bits, how to highlight is each layer of layered algorithm needs to be considered. At the beginning of this chapter, I did not pay attention to the function of the bit plane layering, thinking that we simply extracted the bits from each layer to build the bit plan. So the following algorithm is available:

The color below is all about grayscale.

`private int Bitlevel (int color, int level) {int color_lev1 = color & 1;   00000001int Color_lev2 = color & 0x2; 00000010int color_lev3 = color & 0x4; 00000100int color_lev4 = color & 0x8; 00001000int color_lev5 = color & 0x10;//00010000int color_lev6 = color & 0x20;//00100000int color_lev7 = color & Amp 0x40;//01000000int color_lev8 = color & 0x80;//10000000int color_lev;//= color & 0x80;color_lev = color & (1 << level)//level value is 0 to 7return (255 << +) + (Color_lev << +) + (Color_lev << 8) + Color_lev;}`

The function of this algorithm is to extract the bits of each layer simply, but I ignore the gist of "highlighting this layer bit". The actual results also proved to be wrong, such as the first layer, the value is not 0 is 1, such a color value shows that is pure black, can not show the contribution of the first layer of bits. The best way to highlight layering is to be binary, because each pixel has a value of only 1 (contribution) and 0 (no contribution) per layer of bits, and what we have to do is highlight the value of 1. The real layering algorithm is as follows:

First Floor:

Values at the first level can only be 0 and 1, so the value is 0 o'clock, which translates to a value of 255

`private int Bitlevelone (int color) {int Gray = Color >> 8 & 0xff;int color_lev;if (Gray = = 1) Color_lev = 255;else Color_lev = 0;return (255 <<) + (Color_lev << +) + (Color_lev << 8) + Color_lev;}`

(The experiment is in the "Digital image processing," the sample provided in the picture for processing, the figure itself is a 8-bit grayscale, the parameter value passed to the function is ARGB pixel value, the value is a=r=g=b, so take out the right 8 bits to get its grayscale image, the same for "highlight" consideration, alpha channel 255)

Original image: (500x1192 pixels of grayscale)

First Floor plan:

Other tiers of layered algorithms, such as the above, if the bit value of this level is 1, then two is value 255, if 0, then two is value 0. For example, the sixth layered algorithm is as follows

`private int bitlevelsixth (int color) {int Gray = Color >> 8 & 0xff;int color_lev6 = Gray & 0x20;//00100000i  NT Color_lev;if (color_lev6 = = 0x20) Color_lev = 255;elsecolor_lev = 0;return (255 << +) + (Color_lev << 16) + (Color_lev << 8) + Color_lev;}`

Note: The above algorithm involves a variety of shifts and other operations, the actual results of low efficiency, this is not considered here, only to illustrate the actual bit plane layering algorithm principle.

The results of section 6,7,8 are as follows:

Another application of the bit plane layering is that in image compression, from the results of the above layered graphs, we only need to use the higher-order layers to reconstruct the original artwork, which means that you can use a smaller bit layer than the original (such as 4 layers, which reduces the storage volume by 50%).

The algorithm and results of three planar reconstruction using 6,7,8 are as follows:

`private int combine678 (int color) {int Gray = Color >> 8 & 0xff;int colors = Gray & 0xe0;//11100000return (25 5 <<) + (colors << +) + (colors << 8) + colors;}`

(6) Bit plane layering (bit Plane slicing)

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.