Plot rectangle from top area to center in picture
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 4 Mär. 2017
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 Kommentare
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!