Joschka
2012-07-10 12:27:15 UTC
Hi everyone,
first of all I would like to congratulate all contributors on their
efforts, this package looks very promising to me. I plan on using the
plotting and interaction possibilities to rapidly develop image processing
utilities.
Currently I'm working on a perspective distortion tool which requires the
user to select four points in an image and then uses these points to
compute a homography for distortion correction (points are mapped to
corners of a square). As these points should be placed precisely, getting
the mouse cursor coordinates at the time of the click event is not enough.
After looking at your image_plot_tools.py example the AnnotatedPointTool
seems appropriate. However, I want to place these four points
programmatically to provide the user with an initial guess of the position
which she can change later. So I modified the example (see below) to
display four points with their corresponding labels and make them
selectable and movable. Now, the user can select these points by clicking
on an invisible point above the top left corner of the annotation frame and
move them to the correct position.
I want to display some symbol to make the selection and placement easier.
The GUI enables me to do this, by selecting one point (using the invisible
marker) and opening the Parameters window, where I can set a symbol on the
Shape or Label register. How can I achieve this in my program? I would
prefer to have a red cross as corner marker...
Thanks in advance!
Best Regards,
Joschka
Code example
----------------------
import os.path as osp
from guiqwt.plot import ImageDialog
from guiqwt.builder import make
import guiqwt.annotations as ga
from guiqwt.styles import AnnotationParam
def create_window():
win = ImageDialog(edit=False, toolbar=True,
wintitle="BIGS Corner Selection")
return win
def test():
"""Test"""
# -- Create QApplication
import guidata
_app = guidata.qapplication()
# --
filename = osp.join(osp.dirname(__file__), "brain.png")
win = create_window()
image = make.image(filename=filename, colormap="gray",
interpolation="nearest")
plot = win.get_plot()
plot.add_item(image)
corner_positions = [(-10, 0), (100, 0), (0, 100), (100, 100)]
corner_titles = ["Top Left", "Top Right", "Bottom Left", "Bottom Right"]
for point, title in zip(corner_positions, corner_titles):
parameters = AnnotationParam()
parameters.title = title
annotation = ga.AnnotatedPoint(point[0], point[1], parameters)
annotation.set_movable(True)
annotation.set_selectable(True)
plot.add_item(annotation)
win.exec_()
if __name__ == "__main__":
test()
first of all I would like to congratulate all contributors on their
efforts, this package looks very promising to me. I plan on using the
plotting and interaction possibilities to rapidly develop image processing
utilities.
Currently I'm working on a perspective distortion tool which requires the
user to select four points in an image and then uses these points to
compute a homography for distortion correction (points are mapped to
corners of a square). As these points should be placed precisely, getting
the mouse cursor coordinates at the time of the click event is not enough.
After looking at your image_plot_tools.py example the AnnotatedPointTool
seems appropriate. However, I want to place these four points
programmatically to provide the user with an initial guess of the position
which she can change later. So I modified the example (see below) to
display four points with their corresponding labels and make them
selectable and movable. Now, the user can select these points by clicking
on an invisible point above the top left corner of the annotation frame and
move them to the correct position.
I want to display some symbol to make the selection and placement easier.
The GUI enables me to do this, by selecting one point (using the invisible
marker) and opening the Parameters window, where I can set a symbol on the
Shape or Label register. How can I achieve this in my program? I would
prefer to have a red cross as corner marker...
Thanks in advance!
Best Regards,
Joschka
Code example
----------------------
import os.path as osp
from guiqwt.plot import ImageDialog
from guiqwt.builder import make
import guiqwt.annotations as ga
from guiqwt.styles import AnnotationParam
def create_window():
win = ImageDialog(edit=False, toolbar=True,
wintitle="BIGS Corner Selection")
return win
def test():
"""Test"""
# -- Create QApplication
import guidata
_app = guidata.qapplication()
# --
filename = osp.join(osp.dirname(__file__), "brain.png")
win = create_window()
image = make.image(filename=filename, colormap="gray",
interpolation="nearest")
plot = win.get_plot()
plot.add_item(image)
corner_positions = [(-10, 0), (100, 0), (0, 100), (100, 100)]
corner_titles = ["Top Left", "Top Right", "Bottom Left", "Bottom Right"]
for point, title in zip(corner_positions, corner_titles):
parameters = AnnotationParam()
parameters.title = title
annotation = ga.AnnotatedPoint(point[0], point[1], parameters)
annotation.set_movable(True)
annotation.set_selectable(True)
plot.add_item(annotation)
win.exec_()
if __name__ == "__main__":
test()