matlab lpfilter.m,histroi/statmoments/lpfilter/dftuv的Matlab程序
(摘自冈萨雷斯的《数字图像处理(使用Matlab)》)
:
l function [P,npix]=histroi(f,c,r)
% HISTROI Computes the histogram of an ROI
in an image.
% [P,npix]=histroi(f,c,r) computes the
histogram,P,of a
% polygonal region of interest (ROI) in
image F.The polygonal
% region is defined by the colunm and row
coordinates of its
% vertices, which are by the column and
row coordinates of its
% respectively. All pixels of F must be
>=0. Parameter NPIX is
% number of pixels in the polygonal
region.
% ****from ggbondg****
% Generate the binary mask
image.
B=roipoly(f,c,r);
% Compute the histogram of the pixels in
the ROI.
P=imhist(f(B));
%Obtain the number of pixels in ROI if
requested in the output.
if nargout>1
npix=sum(B(:));
end
%****from ggbondg****
l function [v,unv]=statmoments(p,n)
% STATMOMENTS Computes statistical central
moments of image histogram.
% [v,unv]=statmoments(p,n) computes up to
the Nth statistical
% central moment of a histogram whose
components are in vector
% P. The length of must equal 256 or
65536.
% ****from ggbondg****
% The program outputs a V with V(1)=mean,
V(2) = variance.
% V(3) = 3rd moment,...V(N)=Nth central
moment. The random
% variable values are normalized to the
range [0,1], so all
% moments also are in this
range.
% ****from ggbondg****
% The program also outputs a Vector UNV
containing the same moments
% as V,but using un-normalized random
variable values (e.g., 0 to
% 255 if length(P)=2^8). For example, if
length(P)=256 and V(1)
% = 0.5, then UNV(1) would have the value
UNV(1)=127.5 (half of
% the [0 255] range).
%****from ggbondg****
Lp=length(p);
if (Lp~=256)&(Lp~=65536)
error('P
must be a 256- or 65536- elements vector.');
end
G=Lp-1;
% Make sure the histogram has unit area,
and convert it to a
% column vector.
p=p/sum(p);
p=p(:);
% Form a vector of all the possible values
of the
% random variable.
z=0:G;
%****from ggbondg****
% Now normalize the z's to the range
[0,1].
z=z./G;
%****from ggbondg****
% The mean.
m=z*p;
%****from ggbondg****
% Cencter random variable about the
mean.
z=z-m;
%****from ggbondg****
% Compute the central moments.
v=zeros(1,n);
v(1)=m;
for j=2:n
v(j)=(z.^j)*p;
end
%****from ggbondg****
if nargout>1
% Compute the uncentralized
moments.
unv=zeros(1,n);
unv(1)=m.*G;
for
j=2:n
unv(j)=((z*G).^j)*p;
end
end
%****from ggbondg****
l function [H]=lpfilter(type,M,N,D0,n)
% LPFILTER Computes frequency domain
lowpass filters.
% H=lpfilter(type,M,N,D0,n) creates the
transfer function of
% a lowpass filter ,H,of the specified
TYPE and size (M-by-N).To
% view the filter as an image or mesh
plot,it should be centered
% using H=fftshift(H).
% %****from ggbondg****
% Valid values for TYPE,D0,and n
are:
% %****from ggbondg****
%
'ideal' Ideal lowpass filter with cutoff frequency D0. n need
% not be supplied. D0 must be positive.
% %****from ggbondg****
%
'btw' Butterworth lowpass filter of order n, and cutoff
% D0.The default value for n is 1.0. D0 must be positive.
%
% 'gasussian' Gaussian
lowpass filter with cutoff (standard
% deviation) D0. n need not be supplied. D0 must be
% positive.
% %****from ggbondg****
% use function dftuv to set up the
meshgrid arrays needed for
% computing the required
distances.
[U,V]=dftuv(M,N);
%****from ggbondg****
% Compute the distances D(U,V).
D=sqrt(U.^2+V.^2);
%****from ggbondg****
% Begin filter computations.
switch type
case
'ideal'
H=double(D<=D0);
case
'btw'
if nargin==4
n=1;
end
H=1./(1+(D./D0).^(2*n));
case
'gaussian'
H=exp(-(D.^2)./(2*(D0^2)));
otherwise
error('Unknown filter type.')
end
%****from ggbondg****
l function [U,V]=dftuv(M,N)
% DFTUV Computes meshgrid frequency
matrices.
% [U,V]=dftuv(M,N) computes meshgrid
frequency matrices U and V.
% U and V are useful for computing
frequency-domain filter
% functions.U and V are both
M-by-N.
% %****from ggbondg****
% Set up range of variables.
u=0:M-1;
v=0:N-1;
%****from ggbondg****
% Compute the incides for use in
meshgrid.
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
%****from ggbondg****
% Compute the meshgrid arrays.
[V,U]=meshgrid(v,u);
%****from ggbondg****
matlab lpfilter.m,histroi/statmoments/lpfilter/dftuv的Matlab程序相关推荐
- MATLAB计算杨氏模量,四阶弹性模量Cijkl如何在matlab里表示啊? - 计算模拟 - 小木虫 - 学术 科研 互动社区...
matlab 四元数运算计算包就可以了吧 Matlab 四元数操作函数 2012-06-03 21:02:55| 分类: MATLAB&Mathemati | 标签:四元数 quater ...
- 在matlab中有几种获得帮助的途径,matlab经典习题及解答
精品文档 . 1欢迎下载 第1章 MATLAB 概论 1.1 与其他计算机语言相比较,MATLAB 语言突出的特点是什么? MATLAB 具有功能强大.使用方便.输入简捷.库函数丰富.开放性强等特点. ...
- 【数字信号处理】卷积编程实现 ( Matlab 卷积和多项式乘法 conv 函数 | 使用 matlab 代码求卷积并绘图 )
文章目录 一.Matlab 卷积和多项式乘法 conv 函数 二.使用 matlab 代码求卷积并绘图 一.Matlab 卷积和多项式乘法 conv 函数 Matlab 文档地址 : https:// ...
- 让书写的Matlab代码运行更快 Recipes for Faster Matlab Code
Matlab 在 Research 中用得非常多,确实也是非常方便实用,只是有一个问题就是写 Matlab 代码的时候经常需要用一些比较奇怪独特的方式来思考和处理问题,否则写出来的代码虽然同样能工作, ...
- 利用matlab命令画出以下信号的波形,MATLAB实验报告
文档收集于互联网,已重新整理排版.word 版本可编辑,有帮助欢迎下载支持. 1文档来源为:从网络收集整理.word 版本可编辑. 实验一 名称:连续时间信号分析 姓名:王嘉琦 学号:0636 班级: ...
- matlab的guide怎么添加函数,整理:matlab如何添加m_map工具箱
之前安装过m_map工具箱但是一直出错,错误信息的主要内容是关于'没能找到目录下的函数文件',试了很长时间,发现原来是安装位置出现了问题,之前是安装在了'\toolbox\m_map',所以出错了,下 ...
- matlab 连接mysql数据库_【转】matlab 连接 mysql 数据库
首先要安装mysql驱动程序包,详细步骤如下: Step 1: 将mysql-connector-java-5.1.7-bin.jar文件拷贝到......\MATLAB\R2009a\java\ja ...
- matlab比例环节仿真例子,典型环节的MATLAB仿真
<典型环节的MATLAB仿真>由会员分享,可在线阅读,更多相关<典型环节的MATLAB仿真(11页珍藏版)>请在人人文库网上搜索. 1.实验一 典型环节的MATLAB仿真一.实 ...
- 用MATLAB编程正弦稳态相量图,matlab课程设计--利用MATLAB对线性电路正弦稳态特性分析...
matlab课程设计--利用MATLAB对线性电路正弦稳态特性分析 课程设计任务书 学生姓名: 专业班级: 指导教师: 刘 新 华 工作单位:信息工程学院 题 目: 利用MATLAB对线性电路正弦稳态 ...
最新文章
- 如何打赢一场唯快不破的比赛,看看他们的绝招
- ArcGIS API for Silverlight 实现修改地图上的工程点位置
- 数据类型(Python)
- 在doc中生成柱状图_Python从CSV文件导入数据和生成简单图表
- CSS :active 伪类
- python文件名匹配
- 工作占用了太多私人时间_下班后还要被逼谈工作,我们应该如何处理?
- 有了这个算法,图像上文字擦除再也用不上PS了
- ASP.NET本质论阅读----应用程序对象
- cpu超频软件_AMD 锐龙7 3700X(默频)全面对决i7-9700K(超频至5.0GHz)
- 找出数组中出现次数最多的数字和出现次数
- html什么布局可以兼容多平台,腾讯游戏:浅谈游戏官网现状及设计趋势
- 小程序结合腾讯地图(QQMapWX)SDK做位置周边搜索展示
- OpenCV开发笔记(六十):红胖子8分钟带你深入了解Harris角点检测(图文并茂+浅显易懂+程序源码)
- PHP include 和 include_once 的区别
- PTA 1054 求平均值 (20 分)
- android高德地图marker图标,高德地图自定义Marker显示文字
- 百度地图-坐标转换及位置解析
- Accidently in love
- 《Python绝技:运用Python成为顶级黑客》 用Python刺探网络
热门文章
- CIKM 2021 | BH:面向Web级应用的基于二进制码的Hash Embedding
- ROS2学习(十三).ROS概念 - ROS结构(Composition)
- 2021年武大CS\南大CS\哈工CS\浙软\西交CS\天大佐治亚CS\中科院信网中心面试经验贴
- arcgis分隔图层重复出文件_已知坐标点txt文件在ArcGIS中转换成shp数据的两种方法...
- POJ 2054 Color a Tree解题报告
- 各种输出函数的比较(printf/fprintf/sprintf/snprintf/vprintf/vfprintf/vsprintf/vsnprintf)
- source insight 常用设置及快捷键
- airflow使用_使用AirFlow,SAS Viya和Docker像Pro一样自动化ML模型
- 谷歌联合学习的论文_Google的未来联合学习
- gre tunnel源码分析之接收流程