フィルターのクリア

Plot rectangle from top area to center in picture

2 ビュー (過去 30 日間)
Adisorn Phanukthong
Adisorn Phanukthong 2017 年 2 月 24 日
回答済み: Image Analyst 2017 年 3 月 4 日
I want to plot rectangle from top to center picture
i = imread('D:\MATLAB\bwwalk2\bw0012.png');
[y, x] = ndgrid(1:size(i, 1), 1:size(i, 2));
cen = mean([x(logical(i)), y(logical(i))]);
[rows, columns] = find(i);
height = max(rows) - min(rows);
width = max(columns) - min(columns);
%rectangle = int32([10 10 30 30]);
%J = shapeInserter(i, rectangle);
imshow(i);
hold on
rectangle('Position',[min(columns),min(rows),width,""""""""],'LineWidth',2, 'EdgeColor','b');
plot(cen(:,1),cen(:,2),'b*')
hold off
end

回答 (1 件)

Image Analyst
Image Analyst 2017 年 3 月 4 日
Try this:
img = imread('peppers.png');
[rows, columns, numberOfColorChannels] = size(img);
imshow(img);
axis on;
hold on
% Plot rectangle in upper half.
rectangle('Position',[1, 1, columns, rows/2], ...
'LineWidth', 3, 'EdgeColor', 'b');
% Plot star in middle
plot(columns/2, rows/2, 'b*', 'MarkerSize', 30)
hold off

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by