Borrar filtros
Borrar filtros

Plot rectangle from top area to center in picture

2 visualizaciones (últimos 30 días)
Adisorn Phanukthong
Adisorn Phanukthong el 24 de Feb. de 2017
Respondida: Image Analyst el 4 de Mzo. de 2017
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

Respuestas (1)

Image Analyst
Image Analyst el 4 de Mzo. de 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

Community Treasure Hunt

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

Start Hunting!

Translated by