Esempio n. 1
0
    def _gallery_image(self, center, gallery_size=50):
        height, width, zslices, nchannels = self.image.shape
        halfsize = int(np.floor(gallery_size/2.0))

        xmin = center.x - halfsize
        xmax = xmin + gallery_size
        ymin = center.y - halfsize
        ymax = ymin + gallery_size

        if xmin < 0:
            xmin = 0
            xmax = gallery_size
        elif xmax >= width:
            xmin = width - gallery_size
            xmax = width

        if ymin < 0:
            ymin = 0
            ymax = gallery_size
        elif ymax >= height:
            ymin = height - gallery_size
            ymax = height

        zprojection = self.params.values()[0].zprojection

        gimg = self.image[ymin:ymax, xmin:xmax, :, self._channel_idx]
        gimg = zProjection(gimg, zprojection, self.zslice)

        if gimg.dtype == np.dtype('uint8'):
            return gimg
        else:
            return self.normalize(gimg, norm_min=np.floor(gimg.min()),
                                  norm_max=np.ceil(gimg.max()))
Esempio n. 2
0
    def segmentation(self):

        # needed for gallery images
        self._channel_idx = self.channels.keys()
        # the master (primary) channel is determined by the first item
        # the segmentation parameters (OrderedDict)
        # channels_r = OrderedDict([(v, k) for k, v in self.channels.items()])

        # segment the master first
        cname = self.channels[self.imaster]

        image = zProjection(self.image[:, :, :, :].copy(),
                            self.params[cname].zprojection, self.zslice)

        cnt = self.threshold(image[:, :, self.imaster], self.params[cname])


        self._containers[cname] = cnt

        label_image = self._containers[cname].img_labels.toArray()
        self._filter(self._containers[cname], self.params[cname])
        rbo = self.params[cname].remove_borderobjects

        for i, name in self.channels.iteritems():
            if i == self.imaster:
                continue

            self._containers[name] = self.seededRegion( \
                    image[:, :, i], label_image, *self.params[name],
                    remove_borderobjects=rbo)
        self._filterByLabels()
Esempio n. 3
0
    def iterQImages(self, all_channels=True, normalize=True):
        """Iterator over to qimage converted images, one qimage per channel."""
        if all_channels:
            channels = range(self._reader.channels)
        else:
            channels = self.channels.keys()

        zprojection = self.params.values()[0].zprojection

        qimages = list()
        for ci in channels:
            image = zProjection(self.image[:, :, :, ci], zprojection,
                                self.zslice)
            qimages.append(gray2qimage(image, normalize=normalize))

        return qimages