XScale = (Xref_value - origin_value) / np.linalg.norm(OXref) # compute the coordinates of the points in the user-defined system #~ selected_points.sort() # sorts the points in increasing x order Selected_points = plt.ginput(-1,timeout=-1) Print "Note that the keyboard may not work." Print "Middle-click or press 'Enter' to confirm" Print "Left-click or press 'del' to deselect" Print "Right-click or press 's' to select" Yref = promptPoint('Place the Y reference') Xref = promptPoint('Place the X reference') Origin_value = askValue('X origin',0),askValue('Y origin',0) Return tkSimpleDialog.askfloat(text, 'Value:', Return np.array(plt.ginput(1,timeout=-1)) Imgplot = ax.imshow(image, origin=origin) Image = clipboard.wait_for_image().get_pixels_array() If clipboard.wait_is_uris_available(): # it's a path to a file ! While not ( clipboard.wait_is_uris_available() Print "Waiting for an image in the clipboard." # and empties it if it is not a file path # This chunk tries the text content of the clipboard Either provide the graphĪs a path to an image in 'source' or copy it to the clipboard. """ GUI to get data from a XY graph image. Points = pic2data('mozart.jpeg', straight = False)Īfter placing the points and getting their coordinates one can redraw the plot withĭef pic2data(source='clipboard',straight=True): 1: Young Frederic Chopin disguised as Mozart. However if the graph on the picture is not straight, like in a photo, use the argument straight=False.Īs an example, let us take a photo with a graph, like this one.įig. As a consequence the algorithm will automatically replace the reference point you chose for the X axis in order to put it at the same height as the origin, and it will replace the reference point for Y exactly above the origin. This will typically be the case for a graph from a scientific article. Then you can select/deselect as many points of the curve as you want, and exit with the middle button.The list of selected points is returned.īy default the program will consider that the graph is rectangular and parralel to the edges of the pictures (wich I will call straight in what follows). points of these axis whose coordinates you know). You will then be asked you to place the origin of the graph, as well as the coordinates of this origin (in case it it not (0,0)), and one reference point for each axis X and Y (i.e. Alternatively you can use a picture from a file with This will either start a session using the picture from the clipboard, or, if there is none, wait for the clipboard to contain a picture. Stores the points’ coordinates in a python variable and in the clipboard (for use in another application). Advanced interface (left-click to select a point, right-click to deselect).Data extraction from rotated graphs or graphs shown with (moderate) perspective.Data extraction from picture files or from a picture in the clipboard.If you want to transform a picture of a graph into exploitable data (which is very useful in science if you want to exploit a figure from an article without bothering the authors), here is a minimalistic interface written in python with the following features:
0 Comments
Leave a Reply. |