Borrar filtros
Borrar filtros

How to draw lines in between points that the user provides?

2 visualizaciones (últimos 30 días)
Ryan Bowman
Ryan Bowman el 1 de Dic. de 2018
Editada: Adam Danz el 1 de Dic. de 2018
I have a picture uploaded to matlab where I have the user pick four points, then I shall have red lines that are made in between those points that should make a square (or somehat close to a square). I also what to convert the image to grayscale using the 'jet' colormap. This is my code so far:
The x = ... and y = ... is clearly wrong as it makes a seperate figure with lines and the lines are not on the picture.
clc;
close all;
clear;
%%
davis = imread('DavisHall.jpg');
figure(1), imagesc(davis), axis image
PickCorners = ginput(4)
x = [PickCorners(:,1)];
y = [PickCorners(:,2)];
plot(x',y')
hold on
davisgray = rgb2gray(davis)

Respuesta aceptada

Adam Danz
Adam Danz el 1 de Dic. de 2018
Editada: Adam Danz el 1 de Dic. de 2018
"The x = ... and y = ... is clearly wrong as it makes a seperate figure with lines and the lines are not on the picture. "
You need to specify the axis in your call to plot(). After calling imagesc() get the handle to you axis using gca()
h = gca;
hold(h, 'on')
plot(h, x', y')
If you want to draw a square, you'll need to add the first coordinate on to the end of each x and y vector to complete the square.
plot(h, [x;x(1)]', [y;y(1)]')

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by