Matlab在图片上画个半圆和矩形

来源:互联网 发布:sql server count 慢 编辑:程序博客网 时间:2024/05/18 02:59



  1. clc; clear all; close all;
  2. I = imread('rice.png');
  3. [h, w] = size(I);
  4. r = min(h, w)/10;
  5. figure;
  6. imshow(I); hold on;
  7. for i = 1 : 3
  8.     [x0, y0] = ginput(1);
  9.     t = linspace(pi, 2*pi);
  10.     x = x0 + r*cos(t);
  11.     y = y0 + r*sin(t);
  12.     plot(x, y, 'r-', 'LineWidth', 2);
  13.     rectangle('Position',[x0, y0, r, r], ...
  14.         'LineWidth', 2, 'EdgeColor', 'r');
  15. end
复制代码


0 0
原创粉丝点击