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