MATLAB数字图像处理练习八
一,题目
一.车牌号码识别
主要步骤:图像预处理、车牌区域定位、车牌字符分割、车牌字符识别。
二.图像拼接
编写程序,将两幅相邻图像(图1和图2)拼接成一幅全景图像(图3)。
图1:
图2:
图3:
三.哈夫曼编码
已知某信源发出的8个消息,其信源概率分布是不均匀的,分别为{0.1,0.18,0.4,0.05,0.06,0.1,0.07,0.04},请对信源进行哈夫曼编码,并求出三个参数:平均码长、熵及编码效率。
四.算术编码和解码
假设信源符号为{a,b,c,d},假设这些符号出现的概率分别为{0.2,0.2,0.4,0.2} ,写出对信源符号“bdadcadc”进行算术编码和解码的过程。
二,解答
题目一
由于代码较长,这里只展示图片
有需要,请自取:
链接:https://pan.baidu.com/s/17hQBKmhN_mFwL6P4yH5x5w
提取码:sxqy
题目二
由于代码较长,这里只展示图片
有需要,请自取:
链接:https://pan.baidu.com/s/1XMlyH1fMehi4z1QZB0642g
提取码:sxqy
题目三
huffman.m文:
function CODE = huffman(p)
%HUFFMAN Builds a variable-length Huffman code for a symbol source.
% CODE = HUFFMAN(P) returns a Huffman code as binary strings in
% cell array CODE for input symbol probability vector P. Each word
% in CODE corresponds to a symbol whose probability is at the
% corresponding index of P.
%
% Based on huffman5 by Sean Danaher, University of Northumbria,
% Newcastle UK. Available at the MATLAB Central File Exchange:
% Category General DSP in Signal Processing and Communications. % Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
% Digital Image Processing Using MATLAB, Prentice-Hall, 2004
% $Revision: 1.5 $ $Date: 2003/10/26 18:37:16 $% Check the input arguments for reasonableness.
error(nargchk(1, 1, nargin));
if (ndims(p) ~= 2) | (min(size(p)) > 1) | ~isreal(p) | ~isnumeric(p)error('P must be a real numeric vector.');
end% Global variable surviving all recursions of function 'makecode'
global CODE
CODE = cell(length(p), 1); % Init the global cell arrayif length(p) > 1 % When more than one symbol ...p = p / sum(p); % Normalize the input probabilitiess = reduce(p); % Do Huffman source symbol reductionsmakecode(s, []); % Recursively generate the code
else CODE = {'1'}; % Else, trivial one symbol case!
end; %-------------------------------------------------------------------%
function s = reduce(p);
% Create a Huffman source reduction tree in a MATLAB cell structure
% by performing source symbol reductions until there are only two
% reduced symbols remainings = cell(length(p), 1);% Generate a starting tree with symbol nodes 1, 2, 3, ... to
% reference the symbol probabilities.
for i = 1:length(p)s{i} = i;
endwhile numel(s) > 2[p, i] = sort(p); % Sort the symbol probabilitiesp(2) = p(1) + p(2); % Merge the 2 lowest probabilitiesp(1) = []; % and prune the lowest ones = s(i); % Reorder tree for new probabilitiess{2} = {s{1}, s{2}}; % and merge & prune its nodess(1) = []; % to match the probabilities
end%-------------------------------------------------------------------%
function makecode(sc, codeword)
% Scan the nodes of a Huffman source reduction tree recursively to
% generate the indicated variable length code words.% Global variable surviving all recursive calls
global CODE if isa(sc, 'cell') % For cell array nodes,makecode(sc{1}, [codeword 0]); % add a 0 if the 1st elementmakecode(sc{2}, [codeword 1]); % or a 1 if the 2nd
else % For leaf (numeric) nodes,CODE{sc} = char('0' + codeword); % create a char code string
end
调用函数
% function huffmanBIANMA p=[0.1 0.18 0.4 0.05 0.06 0.1 0.07 0.04];
%p=[0.12 0.16 0.3 0.05 0.06 0.2 0.07 0.04];
code=huffman(p)
题目四
算数编码函数:
%算数编码函数
function acode = suanshubianma(symbol,ps,inseq)
high_range=[];
for k=1:length(ps)high_range=[high_range sum(ps(1:k))];
end
low_range=[0 high_range(1:length(ps)-1)];
sbidx=zeros(size(inseq));
for i=1:length(inseq)sbidx(i)=find(symbol==inseq(i));
end
low=0;
high=1;
for i=1:length(inseq)range=high-low;high=low+range*high_range(sbidx(i));low=low+range*low_range(sbidx(i));
end
acode=low;
end
算术解码函数
%算术解码函数
function symbos=suanshujiema(symbol,ps,codeword,symlen)
high_range=[];
for k=1:length(ps)high_range=[high_range sum(ps(1:k))];
end
low_range=[0 high_range(1:length(ps)-1)];
psmin=min(ps);
symbos=[];
for i=1:symlenidx=max(find(low_range<=codeword));codeword=codeword-low_range(idx);if abs(codeword-ps(idx))<0.01*psminidx=idx+1;codeword=0;endsymbos=[symbos symbol(idx)];codeword=codeword/ps(idx);if abs(codeword)<0.01*psmini=symlen+1;end
end
主函数
%主函数
clc
clear
symbol=['abcd'];
ps=[0.2 0.2 0.4 0.2];
inseq='bdadc';
format long e
codeword=suanshubianma(symbol,ps,inseq);
outseq=suanshujiema(symbol,ps,codeword,length(inseq));
MATLAB数字图像处理练习八相关推荐
- 使用 matlab 数字图像处理(八)—— 画圆
0:黑色,1:白色: h = 256; w = 256; r = 70; % 分别表示:高,宽,内部圆的半径 I = ones(h, w); [x, y] = meshgrid(1:w, 1:h); ...
- MATLAB数字图像处理系统[多功能]
MATLAB数字图像处理系统[多功能] 目录 实验一 MATLAB数字图像处理初步 实验二 图像的代数运算 实验三 图像增强-空间滤波 实验四 图像分割 2 实验一 MATLAB数字图像处理初步 一. ...
- 《精通Matlab数字图像处理与识别》一6.2 傅立叶变换基础知识
本节书摘来自异步社区<精通Matlab数字图像处理与识别>一书中的第6章,第6.2节,作者 张铮 , 倪红霞 , 苑春苗 , 杨立红,更多章节内容可以访问云栖社区"异步社区&qu ...
- matlab fspeical,MATLAB数字图像处理.doc
MATLAB数字图像处理 MATLAB常用图像操作 转换图像类型 例1.对一幅图像进行二值化处理,代码及结果如下: load trees BW=im2bw(X,map,0.4); imshow(X,m ...
- Matlab数字图像处理——图像处理工具箱Image Processing Toolbox
Image Processing Toolbox 图像处理工具箱包含的功能: 图像的读取和保存 图像的显示 创建GUI 图像的几何变换 图像滤波器设计及线性滤波 形态学图像处理 图像域变换 图像增强 ...
- Matlab数字图像处理——图像文件的读取
文章目录 一.Matlab中获取图像信息的函数 imfinfo 二.Matlab读取图像文件的函数 imread 三.Matlab保存图像文件的函数 imwrite 完整目录 一.Matlab中获取图 ...
- matlab数字图像处理课程设计报告,数字图像处理初步-实验1
MATLAB数字图像处理初步 通过实验对MatLab软件的基本使用基本的了解,学会使用MatLab软件来读取一个特定格式的图像,并通过相关的命令语句对图像进行格式转换.图像压缩.二值化等的处理,掌握利 ...
- matlab对于处理数字图像的优点,学习MATLAB数字图像处理经验谈
学习MATLAB数字图像处理经验谈 学习数字图像处理经验谈 (赵小川) 一.面向应用:层层分解.抓住要点 我们学习数字图像处理的最终目的还是应用,不管是用它来研制产品还是研发项目抑或是研究课题,都要用 ...
- 【基于matlab数字图像处理GUI代码】_数字图像处理考核论文_大作业_项目
基于matlab数字图像处理GUI代码 代码: function varargout = Image_processing_GUI(varargin) % IMAGE_PROCESSING_GUI M ...
- MATLAB说明图像增强,MATLAB数字图像处理(二)图像增强
1 图像增强 1.1 直方图均衡化 对于灰度图像,可以使用直方图均衡化的方法使得原图像的灰度直方图修正为均匀的直方图. 代码如下: 1 2 3I2=histeq( ...
最新文章
- OpenSCAD 建模:矿泉水瓶盖
- php和python和java-Java、Python与PHP的虚拟机异同
- 机器学习教会我们的六件事
- 面试字节我被String类的问题给问死了!
- php53 php55区别,详解 PHP 中的三大经典模式
- 1030. 完美数列(25)
- ONVIF Device Manager修改设备密码
- java sql server 2016_SQL server 2016 安装步骤
- 《Python程序设计开发宝典》第一波转发积攒活动中奖名单
- LA 2572 Viva Confetti (Geometry.Circle)
- SQL*Loader 和 Data Pump
- 基于云计算的数字化业务系统安全工程
- matlab lu分解 源代码,矩阵的LU分解(Matlab程序)
- stm32f103呼吸灯(PWM脉冲宽度调制)
- 【资讯】创业加速器Satoshi Block Dojo——为BSV前沿初创企业的发展提速
- poj1753Flip Game
- linux搜索log文件的内容
- javac java编译-g
- Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/
- 特征提取算法_基于特征选择与特征提取融合的鸡蛋新鲜度光谱快速检测模型优化...