function s = subim(f,m,n,rx,cy)
%f: 原图像
%m: 子图像的行(相当于高)
%n: 子图像的列(相当于宽)
%rx,cy:分别表示子图像左上角的起始坐标
s = zeros(m,n);%创建一个矩阵,大小为m×n
imshow(uint8(s));
rowhigh = rx+m-1;%计算子图像在原图像的行位置
colhigh = cy+n-1;%计算子图像在原图像的列位置
xcount = 0;%开始遍历
for r = rx:rowhigh%遍历。针对逐个像素点进行复制。
xcount = xcount + 1;
ycount = 0;
for c = cy:colhigh
ycount = ycount + 1;
s(xcount,ycount) = f(r,c);
end
end
subim.m
最新推荐文章于 2022-12-28 10:59:00 发布