基于FPGA的比特平面分層
掃描二維碼
隨時隨地手機看文章
基于FPGA的比特平面分層
1 背景知識
像素是由比特組成的數(shù)字。例如,在256級灰度圖像中,每個像素的灰度是由8比特(也就是1個字節(jié))組成。一幅8比特圖像可以認為由8個1比特平面組成,如圖1所示,其中平面1包含圖像中所有像素的最低階比特,而平面8包含圖像中所有像素的最高階比特。
圖1 8比特圖像8層示意
把一幅圖像分解為比特平面,對于分析圖像中每個比特的相對重要性是很有用的,這一處理可幫助我們確定用于量化該圖像的比特數(shù)的充分性。
2 FPGA實現(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
實驗結(jié)果:
圖3 實驗原圖
圖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é)果分析:
對于圖3中(x,y)點的灰度值由8比特層平面相應點組成?;叶葓D像的分層對圖像壓縮很有作用,在圖像壓縮中,重建一幅圖像時所用的平面要比全部平面少。
圖12 灰度圖像重建
圖12 a使用比特平面8和7重建的圖像;b使用比特平面8,7和6重建的圖像;c使用比特8,7,6和5重建的圖像。將圖c與圖a進行對比。