User selected points from a plot
Afficher commentaires plus anciens
I need to visually inspect a certain metric and select the points that are good. I have something that works but it seems like there should be a better way to do this. My main issue is that the only functions I found selected a random spot on the axes and I would like to limit it to only selecting data points. I wrote a solution but it won't work with tightly spaced data points.
Is there a better way for a user to select points from a plot?
Code Below:
function [TotalImage,Points] = PickPeakImages(Struct);
%% Struct(1) is an NxNxi image array
% Struct(2) is time informations for each image
% Struct(5) is a measured value for each image
FN = fieldnames(Struct);
l = length(FN);
TotalImage = [];
Points = [];
f = figure;
title('Select Points then Press Enter')
for Si = 1:l
plot(Struct(2).(FN{Si}),Struct(5).(FN{Si}))
title('Select Points then Press Enter')
[x,~] = getpts(f); % I would like to select points from a plot and this is the closest I could find.
Points = cat(1,Points,x);
for xi = 1:length(x)
ImageIndex = (abs(Struct(2).(FN{Si}) - x(xi)) == min(abs(Struct(2).(FN{Si}) - x(xi)))); % Can't select a point from the plot itself so this gets the right index. It's ok for this purpose but really slow.
TotalImage = cat(3,TotalImage,Struct(1).(FN{Si})(:,:,ImageIndex));
end
end
close(f)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!