当前位置:网站首页>[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
边栏推荐
- ROS+Gazebo中红绿黄交通灯如何实现?
- NER中BiLSTM-CRF解读Forward_algorithm
- 投资同业存单基金是靠谱吗,同业存单基金安全吗
- 【历史上的今天】6 月 18 日:京东诞生;网店平台 Etsy 成立;Facebook 发布 Libra 白皮书
- 毕业总结
- 【历史上的今天】6 月 1 日:Napster 成立;MS-DOS 原作者出生;谷歌出售 Google SketchUp
- SQL injection bypass (3)
- 【历史上的今天】5 月 31 日:Amiga 之父诞生;BASIC 语言的共同开发者出生;黑莓 BBM 停运
- 关于st-link usb communication error的解决方法
- 如何以数据驱动「客户全生命周期管理」,提高线索转化率及客户满意度?
猜你喜欢
![[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

毕业季来临,2022届高校毕业生人数首次突破千万大关

SQL injection bypass (V)

数智学习|湖仓一体实践与探索

【二維碼圖像矯正增强】基於MATLAB的二維碼圖像矯正增强處理仿真

【历史上的今天】6 月 15 日:第一个手机病毒;AI 巨匠司马贺诞生;Chromebook 发布

设计电商秒杀系统

Win11新建不了文本文档?Win11右键无法新建文本文档的解决方法

Win11无法使用动态壁纸怎么办?Win11用不了动态壁纸的解决方法

Win11不能拖拽圖片到任務欄軟件上快速打開怎麼辦
随机推荐
11 timers for STM32F103
【历史上的今天】6 月 10 日:Apple II 问世;微软收购 GECAD;发明“软件工程”一词的科技先驱出生
【历史上的今天】6 月 7 日:Kubernetes 开源版本发布;《魔兽世界》登陆中国;分组交换网络发明者出生
flask基础:模板继承+静态文件配置
NER中BiLSTM-CRF解读Forward_algorithm
ScheduledThreadPoolExecutor源码解读(二)
Dynamic Host Configuration Protocol
ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)
OSI 7层模型讲解(大白话 通俗易懂)
The system administrator has set the system policy to prohibit this installation. Solution
General timer and interrupt of stm32
ROS+Gazebo中红绿黄交通灯如何实现?
【历史上的今天】6 月 8 日:万维网之父诞生;PHP 公开发布;iPhone 4 问世
KVM相关
在线JSON转PlainText工具
【历史上的今天】6 月 20 日:MP3 之父出生;富士通成立;谷歌收购 Dropcam
云平台kvm迁移本地虚拟机记录
Flutter 使用 CustomPaint 绘制基本图形
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
Cvpr22 collected papers | hierarchical residual multi granularity classification network based on label relation tree