zoukankan      html  css  js  c++  java
  • 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


    版权归原创作者所有

  • 相关阅读:
    网站首页蒙灰CSS样式
    MATLAB数值计算编程题
    通过P/Invoke控制继电器
    Java实习生入职测试
    navicat for mongodb12破解
    用svg绘制圣诞帽
    Excel条件格式
    10道算法题
    从事软件开发工作10年后的总结
    ASP.NET Core MVC+EF Core从开发到部署
  • 原文地址:https://www.cnblogs.com/xfzhang/p/1886112.html
Copyright © 2011-2022 走看看