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

相关推荐
gorgeous(๑>؂<๑)1 分钟前
【ICLR26-Oral Paper-Meta】先见之明:揭秘语言预训练中大型语言模型的视觉先验
人工智能·深度学习·算法·机器学习·语言模型
格林威4 分钟前
Baumer相机汽车雨刮胶条磨损检测:实现寿命预测的 6 个关键技术,附 OpenCV+Halcon 实战代码!
人工智能·opencv·计算机视觉·汽车·视觉检测·工业相机·堡盟相机
tod1135 分钟前
力扣基础算法分类刷题:位运算、数学、数组与字符串详解
算法·leetcode·职场和发展
ValhallaCoder5 分钟前
hot100-图论
数据结构·python·算法·图论
熬了夜的程序员7 分钟前
【LeetCode】118. 杨辉三角
linux·算法·leetcode
智算菩萨9 分钟前
规模定律的边际递减与后训练时代的理论重构
人工智能·算法
kanhao10010 分钟前
电平交叉采样 (Level-Crossing Sampling)
算法·fpga开发·fpga
Hcoco_me10 分钟前
图像分割:目标检测、语义分割和实例分割
人工智能·深度学习·算法·目标检测·计算机视觉·目标跟踪
iAkuya10 分钟前
(leetcode)力扣100 69有效的括号(栈)
算法·leetcode·职场和发展
We་ct13 分钟前
LeetCode 21. 合并两个有序链表:两种经典解法详解
前端·算法·leetcode·链表·typescript