Ejemplo n.º 1
0
    def calcFeature(self, imgContainer, pos, t, channels, primary_channel):

        primary_filename = os.path.join(
            self.inDir, imgContainer[pos][t][primary_channel]['path'],
            imgContainer[pos][t][primary_channel]['filename'])
        imgMask = self.getBackgroundROI(primary_filename)

        res = {}
        for channel in channels:
            filename = os.path.join(self.inDir,
                                    imgContainer[pos][t][channel]['path'],
                                    imgContainer[pos][t][channel]['filename'])
            imgIn = ccore.readImageUInt16(filename)

            if self.oSettings.write_images:
                plate = os.path.split(os.path.realpath(self.inDir))[-1]
                outFilenameBase = os.path.join(
                    self.oSettings.output_images_dir, plate, pos,
                    imgContainer[pos][t][channel]['filename'])
            else:
                outFilenameBase = None
            res[channel] = self.getBackgroundForImage(imgIn, imgMask,
                                                      outFilenameBase)

        return
Ejemplo n.º 2
0
    def getBackgroundROI(self, primary_name):

        imgIn = ccore.readImageUInt16(primary_name)
        imgConv = ccore.conversionTo8Bit(imgIn, 2**15, 2**15 + 4096, 0, 255)
        imgSeg = ccore.window_average_threshold(imgConv, 50, 3)
        imgDil = ccore.dilate(imgSeg, 20, 8)
        imgMask = ccore.threshold(imgDil, 1, 255, 255, 0)

        return imgMask
Ejemplo n.º 3
0
    def get_image(self, coordinate):
        index = 0
        zslice = coordinate.zslice
        if self.has_multi_images and self.multi_image == self.MULTIIMAGE_USE_ZSLICE:
            index = zslice - 1
            zslice = None

        filename_rel = self.dimension_lookup[coordinate.position][coordinate.time][coordinate.channel][zslice]
        filename_abs = os.path.join(self.path, filename_rel)
        # make sure no back-slashes are left in the path
        filename_abs = filename_abs.replace("\\", "/")
        if self.meta_data.pixel_type == PixelType.name(PixelType.Uint8):
            image = ccore.readImage(filename_abs, index)
        elif self.meta_data.pixel_type == PixelType.name(PixelType.Uint16):
            image = ccore.readImageUInt16(filename_abs, index)
        else:
            image = ccore.readImageUInt16(filename_abs, index)
        return image
Ejemplo n.º 4
0
 def get_image(self, coordinate):
     index = 0
     zslice = coordinate.zslice
     if (self.has_multi_images
             and self.multi_image == self.MULTIIMAGE_USE_ZSLICE):
         index = zslice - 1
         zslice = None
     filename_rel = self.dimension_lookup[coordinate.position] \
                                         [coordinate.time] \
                                         [coordinate.channel] \
                                         [zslice]
     filename_abs = os.path.join(self.path, filename_rel)
     # make sure no back-slashes are left in the path
     filename_abs = filename_abs.replace('\\', '/')
     if self.meta_data.pixel_type == UINT8:
         image = ccore.readImage(filename_abs, index)
     elif self.meta_data.pixel_type == UINT16:
         image = ccore.readImageUInt16(filename_abs, index)
     else:
         image = ccore.readImageUInt16(filename_abs, index)
     return image
Ejemplo n.º 5
0
    def calcFeature(self, imgContainer, pos, t, channels, primary_channel):

        res = {}
        for channel in channels:
            filename = os.path.join(self.inDir,
                                    imgContainer[pos][t][channel]['path'],
                                    imgContainer[pos][t][channel]['filename'])
            imgIn = ccore.readImageUInt16(filename)
            imgConv = ccore.conversionTo8Bit(imgIn, 2**15, 2**15 + 4096, 0,
                                             255)

            res[channel] = self.getFocusMeasurementFilterSeries(
                imgConv, self.method, self.gauss_sizes)

        return res