当前位置:网站首页>[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
边栏推荐
- 低代码DSL里面在数仓中的实践
- Prometheus 2.27.0 new features
- Machine learning (x) reinforcement learning
- The system administrator has set the system policy to prohibit this installation. Solution
- Keil “st-link usb communication error“解决方法
- 简单文件传输协议TFTP
- JS实现滑动拼图验证
- Keil "St link USB communication error" solution
- How to use metauniverse technology to create a better real world
- Mysql查询相关知识(进阶七:子查询
猜你喜欢

关于st-link usb communication error的解决方法

Flashtext, a data cleaning tool, has directly increased the efficiency by dozens of times

SQL 注入绕过(四)

设计电商秒杀系统

【二维码图像矫正增强】基于MATLAB的二维码图像矫正增强处理仿真

Use code binding DataGridView control to display tables in program interface

Opencv——霍夫变换以及遇到的一些问题

低代码DSL里面在数仓中的实践

迪赛智慧数——柱状图(折柱混合图):2021年毕业季租房价格和房租收入比

数据治理与数据标准
随机推荐
【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用
如何开启多语言文本建议?Win11打开多语言文本建议的方法
Cloud native (30) | kubernetes' app store Helm
毕业总结
General timer and interrupt of stm32
Exploration on the construction path of real-time digital warehouse integrating digital intelligence learning and streaming batch
我今天忘带手机了
SQL报了一个不常见的错误,让新来的实习生懵了
【历史上的今天】5 月 29 日:共享软件先驱诞生;ChromeBox 推出;VoodooPC 创始人出生
ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)
云平台kvm迁移本地虚拟机记录
A low-cost method to increase private domain traffic with simple maintenance
Opencv——几何空间变换(仿射变换和投影变换)
Flask基础:模板渲染+模板过滤使用+控制语句
STM32F103的11个定时器
NER中BiLSTM-CRF解读Forward_algorithm
原理图合并中的技巧
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
SQL injection Bypass (2)
LeetCode - Easy - 197