|
12 | 12 |
|
13 | 13 | import numpy as np |
14 | 14 | from PIL import Image |
15 | | -from PyQt5.QtCore import QPoint, QRectF, QSize, Qt |
16 | | -from PyQt5.QtGui import QColor, QImage, QPainter, QPalette, QPixmap |
17 | | -from PyQt5.QtWidgets import (QApplication, QButtonGroup, QCheckBox, QComboBox, |
18 | | - QHBoxLayout, QLabel, QMainWindow, QPushButton, |
19 | | - QSizePolicy, QSpinBox, QTabWidget, QVBoxLayout, |
20 | | - QWidget) |
| 15 | +from qtpy.QtCore import QPoint, QRectF, QSize, Qt |
| 16 | +from qtpy.QtGui import QColor, QImage, QPainter, QPalette, QPixmap |
| 17 | +from qtpy.QtWidgets import ( |
| 18 | + QApplication, QButtonGroup, QCheckBox, QComboBox, |
| 19 | + QHBoxLayout, QLabel, QMainWindow, QPushButton, |
| 20 | + QSizePolicy, QSpinBox, QTabWidget, QVBoxLayout, |
| 21 | + QWidget |
| 22 | +) |
21 | 23 | from skimage.segmentation import flood, flood_fill, mark_boundaries |
22 | 24 | from skimage.util import invert |
23 | 25 | from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis |
@@ -109,7 +111,7 @@ def __init__(self,im_hs,height): |
109 | 111 | self.comboBox.addItem("Local+Global Otsu") |
110 | 112 | self.comboBox.addItem("Niblack") |
111 | 113 | self.comboBox.addItem("Sauvola") |
112 | | - self.comboBox.activated[str].connect(self.threshold_choice) |
| 114 | + self.comboBox.currentTextChanged.connect(self.threshold_choice) |
113 | 115 | self.comboBox.activated.connect(self.updateLocalSize) |
114 | 116 |
|
115 | 117 | self.localtxt = QLabel(self) |
@@ -160,7 +162,7 @@ def __init__(self,im_hs,height): |
160 | 162 | self.imBox.addItem("Image") |
161 | 163 | self.imBox.addItem("Labels") |
162 | 164 |
|
163 | | - self.imBox.activated[str].connect(self.changeIm) |
| 165 | + self.imBox.currentTextChanged.connect(self.changeIm) |
164 | 166 |
|
165 | 167 | leftlay.addWidget(self.label) |
166 | 168 | leftlay.addWidget(self.imagetxt) |
@@ -267,7 +269,7 @@ def __init__(self,im_hs,height): |
267 | 269 | self.clfBox.addItem("Nearest Neighbours") |
268 | 270 | self.clfBox.addItem("Naive Bayes") |
269 | 271 | self.clfBox.addItem("QDA") |
270 | | - self.clfBox.activated[str].connect(self.classifier_choice) |
| 272 | + self.clfBox.currentTextChanged.connect(self.classifier_choice) |
271 | 273 | self.button_lay.addWidget(self.clfBox) |
272 | 274 |
|
273 | 275 |
|
@@ -385,10 +387,10 @@ def getparams(self): |
385 | 387 | self.params = parameters() |
386 | 388 | self.params.generate() |
387 | 389 |
|
388 | | - def changeIm(self): |
389 | | - if str(self.imBox.currentText()) == "Image": |
| 390 | + def changeIm(self, text): |
| 391 | + if text == "Image": |
390 | 392 | self.imflag = "Image" |
391 | | - if str(self.imBox.currentText()) == "Labels": |
| 393 | + if text == "Labels": |
392 | 394 | self.imflag = "Labels" |
393 | 395 |
|
394 | 396 | def changeWatershed(self, state): |
@@ -475,28 +477,28 @@ def undo(self): |
475 | 477 | def return_params(self,params): |
476 | 478 | print(self.params.segment) |
477 | 479 |
|
478 | | - def threshold_choice(self): |
479 | | - if str(self.comboBox.currentText()) == "Otsu": |
| 480 | + def threshold_choice(self, text): |
| 481 | + if text == "Otsu": |
480 | 482 | self.params.segment['threshold'] = "otsu" |
481 | | - elif str(self.comboBox.currentText()) == "Mean": |
| 483 | + elif text == "Mean": |
482 | 484 | self.params.segment['threshold'] = "mean" |
483 | | - elif str(self.comboBox.currentText()) == "Minimum": |
| 485 | + elif text == "Minimum": |
484 | 486 | self.params.segment['threshold'] = "minimum" |
485 | | - elif str(self.comboBox.currentText()) == "Yen": |
| 487 | + elif text == "Yen": |
486 | 488 | self.params.segment['threshold'] = "yen" |
487 | | - elif str(self.comboBox.currentText()) == "Isodata": |
| 489 | + elif text == "Isodata": |
488 | 490 | self.params.segment['threshold'] = "isodata" |
489 | | - elif str(self.comboBox.currentText()) == "Li": |
| 491 | + elif text == "Li": |
490 | 492 | self.params.segment['threshold'] = "li" |
491 | | - elif str(self.comboBox.currentText()) == "Local": |
| 493 | + elif text == "Local": |
492 | 494 | self.params.segment['threshold'] = "local" |
493 | | - elif str(self.comboBox.currentText()) == "Local Otsu": |
| 495 | + elif text == "Local Otsu": |
494 | 496 | self.params.segment['threshold'] = "local_otsu" |
495 | | - elif str(self.comboBox.currentText()) == "Local+Global Otsu": |
| 497 | + elif text == "Local+Global Otsu": |
496 | 498 | self.params.segment['threshold'] = "lg_otsu" |
497 | | - elif str(self.comboBox.currentText()) == "Niblack": |
| 499 | + elif text == "Niblack": |
498 | 500 | self.params.segment['threshold'] = "niblack" |
499 | | - elif str(self.comboBox.currentText()) == "Sauvola": |
| 501 | + elif text == "Sauvola": |
500 | 502 | self.params.segment['threshold'] = "sauvola" |
501 | 503 |
|
502 | 504 | def toggle_fk(self, tool): |
@@ -536,14 +538,14 @@ def change_high_sigma(self): |
536 | 538 | def change_disk(self): |
537 | 539 | self.tsparams.set_global_disk_size(self.spinb3.value()) |
538 | 540 |
|
539 | | - def classifier_choice(self): |
540 | | - if str(self.comboBox.currentText()) == "Random Forest": |
| 541 | + def classifier_choice(self, text): |
| 542 | + if text == "Random Forest": |
541 | 543 | self.classifier = RandomForestClassifier(n_estimators=200) |
542 | | - elif str(self.comboBox.currentText()) == "Nearest Neighbours": |
| 544 | + elif text == "Nearest Neighbours": |
543 | 545 | self.classifier = KNeighborsClassifier() |
544 | | - elif str(self.comboBox.currentText()) == "Naive Bayes": |
| 546 | + elif text == "Naive Bayes": |
545 | 547 | self.classifier = GaussianNB() |
546 | | - elif str(self.comboBox.currentText()) == "QDA": |
| 548 | + elif text == "QDA": |
547 | 549 | self.classifier = QuadraticDiscriminantAnalysis() |
548 | 550 |
|
549 | 551 | def train_classifier(self): |
|
0 commit comments