示例#1
0
    def _binaryzation(self):
        vol_name = str(self.out_edit.text())
        threshold = self.threshold_edit.text()

        if not vol_name:
            self.out_edit.setFocus()
            return
        if not threshold:
            self.threshold_edit.setFocus()
            return

        try:
            threshold = int(threshold)
        except ValueError:
            self.threshold_edit.selectAll()
            return

        source_row = self.source_combo.currentIndex()
        source_data = self._model.data(self._model.index(source_row),
                                       Qt.UserRole + 5)
        if (threshold > source_data.max()) or (threshold < source_data.min()):
            self.threshold_edit.setFocus()
            return
        new_vol = imtool.binaryzation(source_data, threshold)
        self._model.addItem(new_vol,
                            None,
                            vol_name,
                            self._model._data[0].get_header())
        self.done(0)
示例#2
0
    def _binary_erosion(self):
        vol_name = str(self.out_edit.text())
        num = self.structure_combo.currentIndex() + 3
        self.structure_array = np.ones((num, num, num), dtype=np.int)

        if not vol_name:
            self.out_edit.setFocus()
            return

        source_row = self.source_combo.currentIndex()
        source_data = self._model.data(self._model.index(source_row), Qt.UserRole + 5)

        binary_vol = imtool.binaryzation(source_data, (source_data.max() + source_data.min()) / 2)
        new_vol = morphology.binary_erosion(binary_vol, structure=self.structure_array)
        self._model.addItem(new_vol, None, vol_name, self._model._data[0].get_header())
        self.done(0)
    def _binary_erosion(self):
        vol_name = str(self.out_edit.text())
        num = self.structure_combo.currentIndex() + 3
        self.structure_array = np.ones((num, num, num), dtype=np.int)

        if not vol_name:
            self.out_edit.setFocus()
            return

        source_row = self.source_combo.currentIndex()
        source_data = self._model.data(self._model.index(source_row),
                                       Qt.UserRole + 6)

        binary_vol = imtool.binaryzation(
            source_data, (source_data.max() + source_data.min()) / 2)
        new_vol = morphology.binary_erosion(binary_vol,
                                            structure=self.structure_array)
        self._model.addItem(new_vol, None, vol_name,
                            self._model._data[0].get_header())
        self.done(0)
示例#4
0
    def _binaryzation(self):
        vol_name = str(self.out_edit.text())
        threshold = self.threshold_edit.text()

        if not vol_name:
            self.out_edit.setFocus()
            return
        if not threshold:
            self.threshold_edit.setFocus()
            return

        try:
            threshold = float(threshold)
        except ValueError:
            self.threshold_edit.selectAll()
            return

        source_row = self.source_combo.currentIndex()
        source_data = self._model.data(self._model.index(source_row),
                                       Qt.UserRole + 6)
        new_vol = imtool.binaryzation(source_data, threshold)
        self._model.addItem(new_vol, None, vol_name,
                            self._model._data[0].get_header())
        self.done(0)