Plot rectangle from top area to center in picture
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!