straditize.widgets.image_correction module

Image correction methods

Disclaimer

Copyright (C) 2018-2019 Philipp S. Sommer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Classes

ImageRescaler(straditizer_widgets, item, …)

A button to rescale the straditize image

ImageRotator(straditizer_widgets[, item])

Widget to rotate the image

class straditize.widgets.image_correction.ImageRescaler(straditizer_widgets, item, *args, **kwargs)[source]

Bases: straditize.widgets.StraditizerControlBase, PyQt5.QtWidgets.QPushButton

A button to rescale the straditize image

Methods

adjust_orig_limits(*args, **kwargs)

Readjust ax_orig after changes in ax_rescale

adjust_rescaled_limits(*args, **kwargs)

Readjust ax_rescale after changes in ax_orig

close_figs()

Close the fig

draw_figure()

equalize_axes([event])

Set both axes to the same size

raise_figure()

Raise the figure for rescaling

rescale([ask])

Rescale and start a new straditizer

rescale_plot(percentage)

Replot im_rescale after adjustments of the slider

resize_stradi_image(percentage)

Resize the straditizer image

should_be_enabled(w)

Check if a widget should be enabled

start_rescaling()

Create the rescaling figure

Attributes

ax_orig

The matplotlib axes for the im_orig

ax_rescale

The matplotlib axes for the im_rescale

fig

The matplotlib figure for the rescaling

im_orig

The matplotlib image for the original diagram

im_rescale

The matplotlib image for the rescaled diagram

rescaling

Boolean that is true if one of the axes is rescaling

slider

A matplotlib.widgets.Slider for specifying the size of the

adjust_orig_limits(*args, **kwargs)[source]

Readjust ax_orig after changes in ax_rescale

adjust_rescaled_limits(*args, **kwargs)[source]

Readjust ax_rescale after changes in ax_orig

ax_orig = None

The matplotlib axes for the im_orig

ax_rescale = None

The matplotlib axes for the im_rescale

close_figs()[source]

Close the fig

draw_figure()[source]
equalize_axes(event=None)[source]

Set both axes to the same size

fig = None

The matplotlib figure for the rescaling

im_orig = None

The matplotlib image for the original diagram

im_rescale = None

The matplotlib image for the rescaled diagram

raise_figure()[source]

Raise the figure for rescaling

rescale(ask=None)[source]

Rescale and start a new straditizer

Parameters

ask (bool) – Whether to ask with a QMessageBox. If None, it defaults to the straditize.widgets.StraditizerWidgers.always_yes

rescale_plot(percentage)[source]

Replot im_rescale after adjustments of the slider

property rescaling

Boolean that is true if one of the axes is rescaling

resize_stradi_image(percentage)[source]

Resize the straditizer image

Parameters

percentage (float) – A float between 0 and 100 specifying the target size of the straditize.straditizer.Straditizer.image

Returns

The resized image of the current straditizer

Return type

PIL.Image.Image

should_be_enabled(w)[source]

Check if a widget should be enabled

This function checks if a given widget w from the widgets2disable attribute should be enabled or not

Parameters

w (QWidget) – The widget to check

Returns

True, if the widget should be enabled

Return type

bool

slider = None

A matplotlib.widgets.Slider for specifying the size of the rescaled image

start_rescaling()[source]

Create the rescaling figure

class straditize.widgets.image_correction.ImageRotator(straditizer_widgets, item=None, *args, **kwargs)[source]

Bases: straditize.widgets.StraditizerControlBase, PyQt5.QtWidgets.QWidget

Widget to rotate the image

This control mainly adds a QLineEdit txt_rotate to the straditize.widgets.StraditizerWidgets to rotate the image. It also enables the user to specify the rotation angle using two connected CrossMarks. Here the user can decide between a horizontal alignment (btn_rotate_horizontal) or a vertical alignment (btn_rotate_vertical)

Parameters
  • straditizer_widgets (StraditizerWidgets) – The main widget for the straditizer GUI

  • item (QTreeWidgetItem) – The parent item in the StraditizerWidgets.tree. If given, the setup_children() is called with this item

Attributes

angle

The rotation angle from txt_rotate as a float

btn_rotate_horizontal

A QPushButton for horizontal alignment

btn_rotate_vertical

A QPushButton for vertical alignment

txt_rotate

A QLineEdit to display the rotation angle

Methods

draw_figure()

enable_or_disable_widgets(b)

Enable or disable the widgets in this control

remove_marks()

Remove the cross marks used for the rotation angle

rotate_image()

Rotate the image based on the specified angle

should_be_enabled(w)

Check if a widget should be enabled

start_horizontal_alignment()

Start the horizontal alignment

start_rotation()

Start the rotation (if not already started)

start_vertical_alignment()

Start the vertical alignment

update_txt_rotate(*args[, marks])

Update the txt_rotate from the displayed cross marks

property angle

The rotation angle from txt_rotate as a float

btn_rotate_horizontal = None

A QPushButton for horizontal alignment

btn_rotate_vertical = None

A QPushButton for vertical alignment

draw_figure()[source]
enable_or_disable_widgets(b)[source]

Enable or disable the widgets in this control

This method enables or disables the widgets2disable if the should_be_enabled() method evaluates to True

Parameters

b (bool) – If True, enable the widgets, if False, disable them

remove_marks()[source]

Remove the cross marks used for the rotation angle

rotate_image()[source]

Rotate the image based on the specified angle

should_be_enabled(w)[source]

Check if a widget should be enabled

This function checks if a given widget w from the widgets2disable attribute should be enabled or not

Parameters

w (QWidget) – The widget to check

Returns

True, if the widget should be enabled

Return type

bool

start_horizontal_alignment()[source]

Start the horizontal alignment

start_rotation()[source]

Start the rotation (if not already started)

start_vertical_alignment()[source]

Start the vertical alignment

txt_rotate = None

A QLineEdit to display the rotation angle

update_txt_rotate(*args, marks=[], **kwargs)[source]

Update the txt_rotate from the displayed cross marks