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

相关推荐
爪哇部落算法小助手4 分钟前
每日两题day65
数据结构·c++·算法
麒qiqi13 分钟前
【数据结构核心篇】树与哈希(Hash)的原理、特性及实战应用
数据结构·算法·哈希算法
ada7_16 分钟前
LeetCode(python)——543.二叉树的直径
数据结构·python·算法·leetcode·职场和发展
橘颂TA16 分钟前
【剑斩OFFER】算法的暴力美学——颜色分类
数据结构·c++·算法·动态规划
吴秋霖22 分钟前
profileData纯算逆向分析
算法·设备指纹·反爬虫技术
sprintzer22 分钟前
11.26-12.05力扣栈刷题
算法·leetcode·职场和发展
sin_hielo35 分钟前
leetcode 3578
数据结构·算法·leetcode
ShiMetaPi1 小时前
SAM(通用图像分割基础模型)丨基于BM1684X模型部署指南
人工智能·算法·ai·开源·bm1684x·算力盒子
前端小白在前进1 小时前
力扣刷题:无重复字符的最长子串
算法·leetcode·职场和发展
小小的橙菜吖!1 小时前
联合体的学习
学习·算法