def __init__(self, mapper, images): super(ImageProcessor, self).__init__() self.mapper = mapper self._channels = OrderedDict() self.metaimages = dict() for name, image in images.iteritems(): metaimage = MetaImage() metaimage.set_image(ccore.readImage(image)) self.metaimages[name] = [metaimage] self.mapper.setImageSize(metaimage.width, metaimage.height) self._setupChannels(images)
def _run(self, meta_image): image = meta_image.image coords = dict( plate=meta_image.image_container.current_plate, pos=meta_image.coordinate.position, time=meta_image.coordinate.time, zslice=meta_image.coordinate.zslice, channel=meta_image.coordinate.channel, ) main_folder = self.params['segmentation_folder'] #FIXME: This is useful enought to put into an reusable function, maybe in utils? locator = self.params["loader_regex"] % coords locator_split = locator.split('/') locator_match = '/' for loc in locator_split[:-1]: try: match_candidates = os.listdir(main_folder + locator_match) if len(match_candidates) == 0: raise RuntimeError except: raise RuntimeError('No files found in ' + main_folder + locator_match) match_results = [ m.group() for l in match_candidates for m in [re.search(loc, l)] if m ] if len(match_results) != 1: raise RuntimeError('Could not match ' + match_candidates[0] + ' with ' + loc) locator_match += match_results[0] + '/' match_candidates = os.listdir(main_folder + locator_match) match_results = [ m.group() for l in match_candidates for m in [re.search(locator_split[-1], l)] if m ] if len(match_results) == 0: raise RuntimeError('Could not match ', match_candidates[0], 'with', locator_split[-1]) match_result = match_results[0] img = ccore.readImage(main_folder + locator_match + match_result) # img_pre = SegmentationPluginPrimary.prefilter(self, img, 2) # img_bin = SegmentationPluginPrimary.threshold(self, img_pre, 20, 3) container = ccore.ImageMaskContainer(image, img, False) return container
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
def _run(self, meta_image): image = meta_image.image coords = dict( plate = meta_image.image_container.current_plate, pos = meta_image.coordinate.position, time = meta_image.coordinate.time, zslice = meta_image.coordinate.zslice, channel = meta_image.coordinate.channel, ) main_folder = self.params['segmentation_folder'] #FIXME: This is useful enought to put into an reusable function, maybe in utils? locator = self.params["loader_regex"] % coords locator_split = locator.split('/') locator_match = '/' for loc in locator_split[:-1]: try: match_candidates = os.listdir(main_folder + locator_match) if len(match_candidates) == 0: raise RuntimeError except: raise RuntimeError('No files found in ' + main_folder + locator_match) match_results = [m.group() for l in match_candidates for m in [re.search(loc, l)] if m] if len(match_results) != 1: raise RuntimeError('Could not match ' + match_candidates[0] + ' with ' + loc) locator_match += match_results[0] + '/' match_candidates = os.listdir(main_folder + locator_match) match_results = [m.group() for l in match_candidates for m in [re.search(locator_split[-1], l)] if m] if len(match_results) == 0: raise RuntimeError('Could not match ', match_candidates[0], 'with', locator_split[-1]) match_result = match_results[0] img = ccore.readImage(main_folder + locator_match + match_result) # img_pre = SegmentationPluginPrimary.prefilter(self, img, 2) # img_bin = SegmentationPluginPrimary.threshold(self, img_pre, 20, 3) container = ccore.ImageMaskContainer(image, img, False) return container
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