基于FPGA的比特平面分層
掃描二維碼
隨時(shí)隨地手機(jī)看文章
基于FPGA的比特平面分層
1 背景知識(shí)
像素是由比特組成的數(shù)字。例如,在256級(jí)灰度圖像中,每個(gè)像素的灰度是由8比特(也就是1個(gè)字節(jié))組成。一幅8比特圖像可以認(rèn)為由8個(gè)1比特平面組成,如圖1所示,其中平面1包含圖像中所有像素的最低階比特,而平面8包含圖像中所有像素的最高階比特。
圖1 8比特圖像8層示意
把一幅圖像分解為比特平面,對(duì)于分析圖像中每個(gè)比特的相對(duì)重要性是很有用的,這一處理可幫助我們確定用于量化該圖像的比特?cái)?shù)的充分性。
2 FPGA實(shí)現(xiàn)
圖2 FPGA內(nèi)部模塊結(jié)構(gòu)框圖
FPGA源碼:
//------------------------------------------------------------------------------------------------------
// layer
//------------------------------------------------------------------------------------------------------
//assign TFT_rgb = {o_y_8b[7],4'b0,o_y_8b[7],5'b0,o_y_8b[7],4'b0}; //Y The eighth layer
//assign TFT_rgb = {o_y_8b[6],4'b0,o_y_8b[6],5'b0,o_y_8b[6],4'b0}; //Y The seventh layer
//assign TFT_rgb = {o_y_8b[5],4'b0,o_y_8b[5],5'b0,o_y_8b[5],4'b0}; //Y The sixth layer
//assign TFT_rgb = {o_y_8b[4],4'b0,o_y_8b[4],5'b0,o_y_8b[4],4'b0}; //Y The fifth layer
//assign TFT_rgb = {o_y_8b[3],4'b0,o_y_8b[3],5'b0,o_y_8b[3],4'b0}; //Y The fourth layer
//assign TFT_rgb = {o_y_8b[2],4'b0,o_y_8b[2],5'b0,o_y_8b[2],4'b0}; //Y The third layer
//assign TFT_rgb = {o_y_8b[1],4'b0,o_y_8b[1],5'b0,o_y_8b[1],4'b0}; //Y The second layer
assign TFT_rgb = {o_y_8b[0],4'b0,o_y_8b[0],5'b0,o_y_8b[0],4'b0}; //Y The first layer
實(shí)驗(yàn)結(jié)果:
圖3 實(shí)驗(yàn)原圖
圖4 The eighth layer
圖5 The seventh layer
圖6 The sixth layer
圖7 The fifth layer
圖8 The fourth layer
圖9 The third layer
圖10 The second layer
圖11 The first layer
結(jié)果分析:
對(duì)于圖3中(x,y)點(diǎn)的灰度值由8比特層平面相應(yīng)點(diǎn)組成。灰度圖像的分層對(duì)圖像壓縮很有作用,在圖像壓縮中,重建一幅圖像時(shí)所用的平面要比全部平面少。
圖12 灰度圖像重建
圖12 a使用比特平面8和7重建的圖像;b使用比特平面8,7和6重建的圖像;c使用比特8,7,6和5重建的圖像。將圖c與圖a進(jìn)行對(duì)比。