Plot a column from an array by clicking on an image of that array
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brian
el 13 de En. de 2023
Respondida: Image Analyst
el 13 de En. de 2023
Say I have an array an image of which I can display:
ti = magic(32);
figure(1);
imagesc(ti);
I want to be able to click on a pixel in the image frame and have a plot updated to show the column from the original array that includes that pixel.
while 1
figure(1);
[x,y] = ginput;
figure(2);
plot(ti(:,round(x)));
end
Except that this doesn't work.
What I really want is a tool in an image figure which plots the columnar profile if I click the tool on the image.
Thanks.
0 comentarios
Respuesta aceptada
Image Analyst
el 13 de En. de 2023
Try this:
ti = magic(32);
subplot(2, 1, 1);
imshow(ti, [], 'InitialMagnification', 1000)
g = gcf;
g.WindowState = 'maximized';
buttonText = 'OK';
while strcmpi(buttonText, 'OK')
subplot(2, 1, 1);
promptMessage = sprintf('Click a point');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'OK', 'Quit', 'OK');
if contains(buttonText, 'Quit', 'IgnoreCase', true)
return; % or break or continue.
end
[x, y] = ginput(1);
column = round(x);
thisColumn = ti(:, column);
subplot(2, 1, 2);
plot(thisColumn, 'b-', 'LineWidth', 2);
grid on;
caption = sprintf('Column %d', column);
title(caption, 'FontSize', 16)
xlabel('Row', 'FontSize', 16)
ylabel('Value', 'FontSize', 16)
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Errorbars en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!