当前位置:网站首页>[block coding] simulation of image block coding based on MATLAB
[block coding] simulation of image block coding based on MATLAB
2022-06-28 02:43:00 【FPGA and MATLAB】
1. Software version
matlab2013b
2. System Overview
Block coding is also called block truncation coding (block truncation coding, abbreviation BTC) Is a kind of still image coding , The principle is to divide an image into sizes N×N The child is like a block ( Short for sub block ), Because the adjacent pixels in the small block have the correlation of similar brightness , Therefore, only two appropriate brightness values are selected to approximately represent the original brightness of each pixel in the small block , Then it indicates which brightness each pixel in the sub block belongs to .
Still image coding is to study how to make use of the inherent statistical characteristics of images ( Source characteristics ), And the physiology of vision 、 Psychological characteristics ( Sink characteristics ), Or recording equipment ( Such as ordinary photographic negative ) And display devices ( Like TV 、 Monitor ) The characteristics of etc , After compression coding, effective information is extracted from the original image information , Try to get rid of the useless redundant information , In order to efficiently carry out digital transmission or digital storage of images ; However, the restored image similar to the original image can still be obtained during restoration , That is, keep the effective information in the image information .
3. Part of the source code
function code(tp,I)
fd=fopen('btc.bin','w+');
[m,n]=size(I);
fwrite(fd,m,'long');fwrite(fd,n,'long');
I=double(I);
A=zeros(tp);B=zeros(tp);c(1)=0;
for i=1:tp:m
for j=1:tp:n
A=I(i:i+tp-1,j:j+tp-1);
sum_col_A=sum(A,1); % Subblocks are summed by columns
sum_A=sum(sum_col_A,2); % Sum of subblock matrices
mean_A=mean2(A); % The mean value of the sub block
for L=1:tp
for k=1:tp
if A(L,k)>=mean_A
B(L,k)=1;
else
B(L,k)=0;
end
end
end
nozeronum=nnz(B); % Non in image matrix 0 Number of elements
AmulB=times(A,B);
sum_AmulB=sum(sum(AmulB(:,:),1),2);
if nozeronum==0
c(1)=0;
c(2)=0;
else
c(1)=round(sum_AmulB/nozeronum); % Reconstruction level in sub block matrix
if nozeronum==tp*tp
c(2)=c(1);
else
c(2)=round((sum_A-sum_AmulB)/(tp*tp-nozeronum));
end
end
fwrite(fd,B,'ubit1');
fwrite(fd,c,'ubit8');
end
end
fclose(fd);
fd=fopen('btc.bin','r');
m=fread(fd,1,'long');n=fread(fd,1,'long');
A=zeros(m,n);
for i=1:tp:m
for j=1:tp:n
B=fread(fd,[tp,tp],'ubit1');
c(1)=fread(fd,1,'ubit8');
c(2)=fread(fd,1,'ubit8');
for k=1:tp
for L=1:tp
if B(k,L)==0
A(i+(k-1),j+(L-1))=c(2);
else
A(i+(k-1),j+(L-1))=c(1);
end
end
end
end
end
A=uint8(A);
imshow(A);title(' After coding with blocks ')
imwrite(A,'lenabianma.bmp');
fclose(fd);
4. Simulation results
2*2

4*4

8*8

A09-30
边栏推荐
- 文件傳輸協議--FTP
- Cloud native (30) | kubernetes' app store Helm
- 我今天忘带手机了
- Complex and inefficient logistics? Three steps to solve problems in enterprise administration
- 在线JSON转PlainText工具
- 【历史上的今天】6 月 10 日:Apple II 问世;微软收购 GECAD;发明“软件工程”一词的科技先驱出生
- 【历史上的今天】6 月 13 日:分组交换网路的“亲子纠纷”;博弈论创始人出生;交互式电视初现雏形
- Keil "St link USB communication error" solution
- 图灵机启动顺序
- Redis~geospatial (geospatial), hyperloglog (cardinality Statistics)
猜你喜欢

Cloud native (30) | kubernetes' app store Helm

Data governance and data standards

Win11不能拖拽圖片到任務欄軟件上快速打開怎麼辦

How to systematically learn LabVIEW?
![[JS reverse hundreds of examples] I love to solve 2022 Spring Festival problems and receive red envelopes](/img/9b/4e0b5838f8c272e9fbc25eb8ef5efa.jpg)
[JS reverse hundreds of examples] I love to solve 2022 Spring Festival problems and receive red envelopes

From how to use to how to implement a promise

Use code binding DataGridView control to display tables in program interface

Dynamic Host Configuration Protocol

Win11 ne peut pas faire glisser l'image sur le logiciel de la barre des tâches

【历史上的今天】6 月 16 日:甲骨文成立;微软 MSX 诞生;快速傅里叶变换发明者出生
随机推荐
Practice of low code DSL in data warehouse
【历史上的今天】6 月 12 日:美国进入数字化电视时代;Mozilla 的最初开发者出生;3Com 和美国机器人公司合并
flask基础:模板继承+静态文件配置
Dynamic Host Configuration Protocol
yarn下载报错There appears to be trouble with your network connection. Retrying.
4G-learn from great partners
Redis~geospatial (geospatial), hyperloglog (cardinality Statistics)
【历史上的今天】6 月 5 日:洛夫莱斯和巴贝奇相遇;公钥密码学先驱诞生;函数语言设计先驱出生
Domain Name System
文件传输协议--FTP
[2D code image correction and enhancement] simulation of 2D code image correction and enhancement processing based on MATLAB
在线JSON转PlainText工具
SQL injection Bypass (2)
【历史上的今天】6 月 13 日:分组交换网路的“亲子纠纷”;博弈论创始人出生;交互式电视初现雏形
SQL报了一个不常见的错误,让新来的实习生懵了
Use code binding DataGridView control to display tables in program interface
MySQL优化小技巧
批阅2022春季学期课程小论文提交情况
共阳极数码管真值表
Leetcode topic [array] -228- summary interval