示例#1
0
文件: importdlg.py 项目: rhoef/afw
    def showObjects(self):

        if not (self.contoursCb.isChecked() or self.showBBoxes.isChecked()) or self._files is None:
            return

        index = self.slider.value()
        try:
            mp = TiffProcessor(
                self._files[index], self._regex, self.segdlg.segmentationParams(), self.cbar.checkedChannels()
            )

            # first channel for primary segementation
            mp.segmentation()
        except Exception as e:
            QMessageBox.critical(self, "Error", "%s:%s" % (type(e), str(e)))
        finally:
            objects = mp.objects()
            if not objects:
                self.viewer.clearPolygons()
                self.viewer.clearRects()
                return

            if self.contoursCb.isChecked():
                self.cbar.setContours(objects.contours)

            if self.showBBoxes.isChecked():
                self.cbar.drawRectangles(objects.centers.values(), self.segdlg.galSize.value(), isize=mp.size)
示例#2
0
文件: importdlg.py 项目: rhoef/afw
    def showImage(self, index=0):
        # no image directory yet
        if self._files is None:
            return
        try:
            proc = TiffProcessor(
                self._files[index], self._regex, self.segdlg.segmentationParams(), self.cbar.checkedChannels()
            )

        except IndexError:
            return
        self.viewer.clearPolygons()
        self.viewer.clearRects()
        images = proc.iterQImages()
        self.cbar.setImages(images, list(proc.iterprops()))
示例#3
0
文件: importdlg.py 项目: rhoef/afw
    def _initialImage(self, index=0):
        """Process the first image."""

        # don't know nz yet when segmentationParams is called
        self.segdlg.setZSlice(0, block=True)

        proc = TiffProcessor(
            self._files[index], self._regex, self.segdlg.segmentationParams(), self.cbar.checkedChannels()
        )

        images = proc.iterQImages()
        props = list(proc.iterprops())
        self.cbar.addChannels(len(images))
        self.cbar.setImages(images, list(proc.iterprops()))
        state = self.segdlg.blockSignals(True)
        self.segdlg.setRegions(self.cbar.allChannels(), props)
        self.setMaxZSlice(proc.zSlices - 1)
        self.segdlg.blockSignals(state)
        self.slider.setRange(0, len(self._files) - 1)
        self.slider.setValue(index)

        self.showObjects()
示例#4
0
文件: importdlg.py 项目: rhoef/afw
def processBild(file_, regex, segparams, feature_groups, channels):

    try:
        gsize = segparams.values()[0].gallery_size
        mp = TiffProcessor(file_, regex, segparams, channels, gsize)
        mp.segmentation()
        mp.calculateFeatures(feature_groups)
        image = mp.image[:, :, :, channels.keys()]
        objects = mp.objects()
        # cannot return OrderedDict from multiprocessing, so I split the dict
        # and reconstruct it in the main process
    except Exception as e:
        return e
    else:
        return file_, image, objects.values(), objects.feature_names