def make_gallery(self, grey_subimages=True): # n_ch >= 2 n_ch = len(self._channel.merge_regions)+1 self.make_target_dir() holder = self._channel.get_region(self._channel.regkey) for label in holder: iname = self.gallery_name(label) center = holder[label].oCenterAbs gallery = GalleryRGBImage(((n_ch)*self._size, self._size, 3), dtype=np.uint8, nsub=n_ch) for i, (channel, region) in enumerate(self._channel.sub_channels()): image = channel.meta_image.image.toArray() hexcolor = Colors.channel_hexcolor(channel.strChannelId) sholder = channel.get_region(region) sample = sholder[label] roi, coff = self._i_sub_image(center, image.shape) sub_img = self.cut(image, roi) gallery.set_sub_image(i, sub_img, hexcolor, grey_subimages) # contour in a single sub image contour = np.array(sample.crack_contour) - \ np.array(sample.oCenterAbs) contour += self._size/2 + coff gallery.add_contour(i, contour, sample.strHexColor) gallery.draw_contour() gallery.draw_merge_contour(holder[label].strHexColor) vigra.RGBImage(gallery).writeImage(iname)
def meta_images(self, alpha=1.0): """Return a list of image, hexcolor, alpha-value tripples, which is used for ccore.makeRGBImage method. """ images = list() ccolors = dict([(c.strChannelId, False) for c in self._channels.values()]) for channel in self._channels.values(): ccolor = channel.strChannelId if ccolor is not None and not ccolors[channel.strChannelId]: ccolors[channel.strChannelId] = True images.append((channel.meta_image.image, Colors.channel_hexcolor(ccolor), alpha)) return images