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窗函数-矩形窗 三角窗 汉宁窗 海明窗 布拉克曼窗 恺撒窗

相关推荐
小赵起名困难户1 小时前
蓝桥杯备赛1-2合法日期
算法
shichaog1 小时前
腿足机器人之八- 腿足机器人动力学
算法·机器人
悄悄敲敲敲3 小时前
C++:dfs习题四则
c++·算法·深度优先
牛大了20235 小时前
[LeetCode力扣hot100]-二叉树相关手撕题
算法·leetcode·职场和发展
ll7788115 小时前
LeetCode每日精进:20.有效的括号
c语言·开发语言·算法·leetcode·职场和发展
德先生&赛先生5 小时前
LeetCode-633. 平方数之和
数据结构·算法·leetcode
WHATEVER_LEO6 小时前
【每日论文】Latent Radiance Fields with 3D-aware 2D Representations
人工智能·深度学习·神经网络·机器学习·计算机视觉·自然语言处理
MYT_flyflyfly6 小时前
计算机视觉-OpenCV图像处理
图像处理·opencv·计算机视觉
mengyoufengyu7 小时前
算法12-贪心算法
python·算法·贪心算法
SharkWeek.8 小时前
【力扣Hot 100】链表4
算法·leetcode·链表