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

相关推荐
会编程的土豆10 小时前
c语言时间戳从入门到精通
linux·c语言·算法
所谓伊人,在水一方33310 小时前
【机器学习精通】第2章 | 优化算法深度解析:从梯度下降到自适应优化器
人工智能·python·算法·机器学习·信息可视化
Storynone10 小时前
【Day24】LeetCode:122. 买卖股票的最佳时机 II,55. 跳跃游戏,45. 跳跃游戏II,1005. K次取反后最大化的数组和
python·算法·leetcode
沃达德软件10 小时前
视频监控烟火识别技术
图像处理·人工智能·目标检测·计算机视觉·目标跟踪·视觉检测·超分辨率重建
滴滴答滴答答10 小时前
机考刷题之 17&18&19&20&21&22 LeetCode 1248&121&43&93&62&63
算法·leetcode·职场和发展
不懒不懒10 小时前
【Opencv计算机视觉-模版匹配】
人工智能·opencv·计算机视觉
for_ever_love__10 小时前
Objective-C学习 类别和扩展
学习·算法·objective-c
Sakinol#10 小时前
Leetcode Hot 100 ——回溯part02
算法·leetcode
Daydream.V10 小时前
Opencv——模板匹配附项目实战(一)
人工智能·opencv·计算机视觉
ArturiaZ10 小时前
【day53】
开发语言·c++·算法