Skip to content

Commit

Permalink
bilinear interpolation working
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-martinr committed Jan 5, 2022
1 parent c730612 commit 2247837
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pycture/commands/edit_commands/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def bilinear_interpolation(image: QImage, point: (float, float)):

P = R + (Q - R) * q

return P
return round(P)

5 changes: 3 additions & 2 deletions src/pycture/commands/edit_commands/rotate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PyQt5.QtWidgets import QWidget, QMainWindow
from ..command import Command
from .interpolation import nearest_neighbor_interpolation
from .interpolation import bilinear_interpolation, nearest_neighbor_interpolation
from pycture.dialogs import RotateDialog
from pycture.editor import Editor

Expand All @@ -10,6 +10,7 @@ def __init__(self, parent: QWidget):
super().__init__(parent, "Rotate")
self.interpolation_techniques = {
"Nearest neighbour": nearest_neighbor_interpolation,
"Bilinear": bilinear_interpolation,
}

def apply_rotation(self, editor_title, interpolation_technique, angle):
Expand All @@ -23,7 +24,7 @@ def execute(self, main_window: QMainWindow):
# Open dialog
# Connect dialog button to rotate function
self.main_window = main_window
dialog = RotateDialog(main_window, main_window.get_editor_list())
dialog = RotateDialog(main_window, main_window.get_editor_list(), list(self.interpolation_techniques.keys()))
dialog.set_editor(main_window.get_active_editor_name())
dialog.set_interpolation_technique(
list(self.interpolation_techniques.keys())[0])
Expand Down
12 changes: 6 additions & 6 deletions src/pycture/dialogs/rotate_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@


class RotateDialog(QDialog):
# img interpolation size(int, int)
applied = Signal(str, str, tuple)
# img interpolation angle
applied = Signal(str, str, float)

def __init__(self, parent: QMainWindow, editors: List[str], angle_limit = 180):
def __init__(self, parent: QMainWindow, editors: List[str], interpolation_techniques: List[str], angle_limit = 180):
super().__init__(parent, Qt.WindowType.Window)
self.setWindowTitle("Scale")
self.layout = QVBoxLayout()
self.layout.setSizeConstraint(QLayout.SetFixedSize)
self.setLayout(self.layout)
self.angle_limit = angle_limit

self.setup(editors)
self.setup(editors, interpolation_techniques)

self.show()

def setup(self, editors: List[str]):
def setup(self, editors: List[str], interpolation_techniques: List[str]):
layout = QVBoxLayout()
self.layout.addLayout(layout)

self.editors_dropdown = DropdownList(self, editors)
layout.addWidget(self.editors_dropdown)

self.interpolation_dropdown = DropdownList(self, ["Nearest neighbour"])
self.interpolation_dropdown = DropdownList(self, interpolation_techniques)
layout.addWidget(self.interpolation_dropdown)


Expand Down

0 comments on commit 2247837

Please sign in to comment.