def display(self, workspace, figure): '''Show an informative display''' import matplotlib import cellprofiler.gui.figure figure.set_subplots((2, 1)) assert isinstance(figure, cellprofiler.gui.figure.Figure) i = workspace.display_data.i j = workspace.display_data.j angles = workspace.display_data.angle mask = workspace.display_data.mask labels = workspace.display_data.labels count = workspace.display_data.count color_image = np.zeros((mask.shape[0], mask.shape[1], 4)) # # We do the coloring using alpha values to let the different # things we draw meld together. # # The binary mask is white. # color_image[mask, :] = MASK_ALPHA if count > 0: mappable = matplotlib.cm.ScalarMappable( cmap=matplotlib.cm.get_cmap(cpprefs.get_default_colormap())) np.random.seed(0) colors = mappable.to_rgba(np.random.permutation(np.arange(count))) # # The labels # color_image[labels > 0, :] += colors[labels[labels > 0] - 1, :] * LABEL_ALPHA # # Do each diamond individually (because the angles are almost certainly # different for each # lcolors = colors * .5 + .5 # Wash the colors out a little for ii in range(count): diamond = self.get_diamond(angles[ii]) hshape = ((np.array(diamond.shape) - 1) / 2).astype(int) iii = i[ii] jjj = j[ii] color_image[iii - hshape[0]:iii + hshape[0] + 1, jjj - hshape[1]:jjj + hshape[1] + 1, :][diamond, :] += \ lcolors[ii, :] * WORM_ALPHA # # Do our own alpha-normalization # color_image[:, :, -1][color_image[:, :, -1] == 0] = 1 color_image[:, :, :-1] = (color_image[:, :, :-1] / color_image[:, :, -1][:, :, np.newaxis]) plot00 = figure.subplot_imshow_bw(0, 0, mask, self.image_name.value) figure.subplot_imshow_color(1, 0, color_image[:, :, :-1], title=self.object_name.value, normalize=False, sharexy=plot00)
def display(self, workspace, figure): dimensions = workspace.display_data.dimensions if self.blank_image.value: figure.set_subplots((1, 1), dimensions=dimensions) if self.wants_color.value == WANTS_COLOR: figure.subplot_imshow( 0, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions ) else: figure.subplot_imshow_bw( 0, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions ) else: figure.set_subplots((2, 1), dimensions=dimensions) figure.subplot_imshow_bw( 0, 0, workspace.display_data.image_pixel_data, self.image_name.value, dimensions=dimensions ) if self.wants_color.value == WANTS_COLOR: figure.subplot_imshow( 1, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions ) else: figure.subplot_imshow_bw( 1, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions )
def display(self, workspace, figure): dimensions = workspace.display_data.dimensions if self.blank_image.value: figure.set_subplots((1, 1), dimensions=dimensions) if self.wants_color.value == WANTS_COLOR: figure.subplot_imshow(0, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions) else: figure.subplot_imshow_bw(0, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions) else: figure.set_subplots((2, 1), dimensions=dimensions) figure.subplot_imshow_bw(0, 0, workspace.display_data.image_pixel_data, self.output_image_name.value, dimensions=dimensions) if self.wants_color.value == WANTS_COLOR: figure.subplot_imshow(1, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions) else: figure.subplot_imshow_bw(1, 0, workspace.display_data.pixel_data, self.output_image_name.value, dimensions=dimensions)