matlab 图像上生成指定中心,指定大小的矩形窗

用matlab实现在图像上生成指定中心,指定大小的矩形窗(奇数*奇数)

复制代码
function PlaneWin = PlaneWindow(CentreCoorX,CentreCoorY,RadiusX,RadiusY,SizeImRow,SizeImColumn)
% 在图像上生成指定中心,指定大小的矩形窗(奇数*奇数)
%
% Input:
% CentreCoorX(1*1)
% CentreCoorY(1*1)
% RadiusX(1*1)
% RadiusY(1*1)
% SizeImRow(1*1)
% SizeImColumn(1*1)
% Output:
% PlaneWin(SizeImRow*SizeImColumn)
%
% X.F.Zhang (2010/11/24, v1.0)
%
ZEROS_FLAG = 1;
StartRowCoor = CentreCoorX-RadiusX; StartColumnCoor = CentreCoorY-RadiusY;
if StartRowCoor < 1
StartRowCoor = 1;
elseif StartRowCoor >= SizeImRow
error('(1)The Central Coordination isn''t in the image!');
end
if StartColumnCoor < 1
StartColumnCoor = 1;
elseif StartColumnCoor >= SizeImColumn
error('(2)The Central Coordination isn''t in the image!');
end

EndRowCoor = CentreCoorX+RadiusX; EndColumnCoor = CentreCoorY+RadiusY;
if EndRowCoor > SizeImRow
EndRowCoor = SizeImRow;
elseif EndRowCoor <= 0
error('(3)The Central Coordination isn''t in the image!');
end
if EndColumnCoor > SizeImColumn
EndColumnCoor = SizeImColumn;
elseif EndColumnCoor <= 0
error('(4)The Central Coordination isn''t in the image!');
end

PlaneWin = zeros(SizeImRow, SizeImColumn);
if ZEROS_FLAG
for i = StartRowCoor:EndRowCoor
for j = StartColumnCoor:EndColumnCoor
PlaneWin(i,j) = 1;
end
end
end

end

MATLAB窗函数-矩形窗 三角窗 汉宁窗 海明窗 布拉克曼窗 恺撒窗

相关推荐
代码游侠5 小时前
C语言核心概念复习——网络协议与TCP/IP
linux·运维·服务器·网络·算法
2301_763472465 小时前
C++20概念(Concepts)入门指南
开发语言·c++·算法
abluckyboy6 小时前
Java 实现求 n 的 n^n 次方的最后一位数字
java·python·算法
园小异6 小时前
2026年技术面试完全指南:从算法到系统设计的实战突破
算法·面试·职场和发展
m0_706653236 小时前
分布式系统安全通信
开发语言·c++·算法
天天爱吃肉82187 小时前
跟着创意天才周杰伦学新能源汽车研发测试!3年从工程师到领域专家的成长秘籍!
数据库·python·算法·分类·汽车
alphaTao7 小时前
LeetCode 每日一题 2026/2/2-2026/2/8
算法·leetcode
甄心爱学习7 小时前
【leetcode】判断平衡二叉树
python·算法·leetcode
颜酱7 小时前
从二叉树到衍生结构:5种高频树结构原理+解析
javascript·后端·算法
不知名XL8 小时前
day50 单调栈
数据结构·算法·leetcode