def display(self, workspace, figure):
     images = workspace.display_data.images
     names = workspace.display_data.names
     stats = workspace.display_data.stats
     figure.set_subplots((1, len(images)))
     figure.figure.clf()
     nimages = len(images)
     shrink = .05
     for i in range(len(images)):
         rect = [shrink + float(i)/float(nimages),
                 .5+shrink,
                 (1.0-2*shrink)/float(nimages),
                 .45*(1.0-2*shrink)]
         axes = figure.figure.add_axes(rect)
         axes.imshow(images[i], matplotlib.cm.Greys_r)
         axes.set_title(names[i],
                        fontname=cpprefs.get_title_font_name(),
                        fontsize=cpprefs.get_title_font_size())
     rect = [0.1,.1,.8,.35]
     axes = figure.figure.add_axes(rect, frameon = False)
     table = axes.table(cellText=stats,
                        colWidths=[1.0/7.0]*7,
                        loc='center',
                        cellLoc='left')
     axes.set_axis_off()
     table.auto_set_font_size(False)
     table.set_fontsize(cpprefs.get_table_font_size())
示例#2
0
        def display():
            if len(orig_axes.images) > 0:
                # Save zoom and scale if coming through here a second time
                x0, x1 = orig_axes.get_xlim()
                y0, y1 = orig_axes.get_ylim()
                set_lim = True
            else:
                set_lim = False
            for axes, labels, title in ((orig_axes, orig_labels,
                                         "Original: %s" % orig_objects_name),
                                        (keep_axes, orig_labels * mask,
                                         "Objects to keep"),
                                        (remove_axes, orig_labels * (~mask),
                                         "Objects to remove")):

                assert isinstance(axes, matplotlib.axes.Axes)
                labels = renumber_labels_for_display(labels)
                axes.clear()
                if np.all(labels == 0):
                    use_cm = matplotlib.cm.gray
                    is_blank = True
                else:
                    use_cm = cm
                    is_blank = False
                if wants_image_display[0]:
                    outlines = outline(labels)
                    image = workspace.image_set.get_image(
                        self.image_name.value)
                    image = image.pixel_data.astype(np.float)
                    image, _ = cpo.size_similarly(labels, image)
                    if image.ndim == 2:
                        image = np.dstack((image, image, image))
                    if not is_blank:
                        mappable = matplotlib.cm.ScalarMappable(cmap=use_cm)
                        mappable.set_clim(1, labels.max())
                        limage = mappable.to_rgba(labels)[:, :, :3]
                        image[outlines != 0, :] = limage[outlines != 0, :]
                    axes.imshow(image)

                else:
                    axes.imshow(labels, cmap=use_cm)
                axes.set_title(title,
                               fontname=cpprefs.get_title_font_name(),
                               fontsize=cpprefs.get_title_font_size())
            if set_lim:
                orig_axes.set_xlim((x0, x1))
                orig_axes.set_ylim((y0, y1))
            figure.canvas.draw()
            panel.Refresh()
示例#3
0
 def run(self, workspace):
     stats = [("Image", "Objects", "Bin # (innermost=1)", "Bin count",
               "Fraction", "Intensity", "COV")]
     d = {}
     for image in self.images:
         for o in self.objects:
             for bin_count_settings in self.bin_counts:
                 stats += \
                 self.do_measurements(workspace,
                                      image.image_name.value,
                                      o.object_name.value,
                                      o.center_object_name.value
                                      if o.center_choice == C_OTHER
                                      else None,
                                      bin_count_settings,
                                      d)
     if workspace.frame is not None:
         images = [d[key][0] for key in d.keys()]
         names = d.keys()
         figure = workspace.create_or_find_figure(
             title="MeasureObjectRadialDistribution, image cycle #%d" %
             (workspace.measurements.image_set_number),
             subplots=(1, len(images)))
         figure.figure.clf()
         nimages = len(images)
         shrink = .05
         for i in range(len(images)):
             rect = [
                 shrink + float(i) / float(nimages), .5 + shrink,
                 (1.0 - 2 * shrink) / float(nimages),
                 .45 * (1.0 - 2 * shrink)
             ]
             axes = figure.figure.add_axes(rect)
             axes.imshow(images[i], matplotlib.cm.Greys_r)
             axes.set_title(names[i],
                            fontname=cpprefs.get_title_font_name(),
                            fontsize=cpprefs.get_title_font_size())
         rect = [0.1, .1, .8, .35]
         axes = figure.figure.add_axes(rect, frameon=False)
         table = axes.table(cellText=stats,
                            colWidths=[1.0 / 7.0] * 7,
                            loc='center',
                            cellLoc='left')
         axes.set_axis_off()
         table.auto_set_font_size(False)
         table.set_fontsize(cpprefs.get_table_font_size())
 def display():
     if len(orig_axes.images) > 0:
         # Save zoom and scale if coming through here a second time
         x0, x1 = orig_axes.get_xlim()
         y0, y1 = orig_axes.get_ylim()
         set_lim = True
     else:
         set_lim = False
     for axes, labels, title in (
         (orig_axes, orig_labels, "Original: %s"%orig_objects_name),
         (keep_axes, orig_labels * mask,"Objects to keep"),
         (remove_axes, orig_labels * (~ mask), "Objects to remove")):
         
         assert isinstance(axes, matplotlib.axes.Axes)
         labels = renumber_labels_for_display(labels)
         axes.clear()
         if np.all(labels == 0):
             use_cm = matplotlib.cm.gray
             is_blank = True
         else:
             use_cm = cm
             is_blank = False
         if wants_image_display[0]:
             outlines = outline(labels)
             image = workspace.image_set.get_image(self.image_name.value)
             image = image.pixel_data.astype(np.float)
             image, _ = cpo.size_similarly(labels, image)
             if image.ndim == 2:
                 image = np.dstack((image, image, image))
             if not is_blank:
                 mappable = matplotlib.cm.ScalarMappable(cmap=use_cm)
                 mappable.set_clim(1,labels.max())
                 limage = mappable.to_rgba(labels)[:,:,:3]
                 image[outlines != 0,:] = limage[outlines != 0, :]
             axes.imshow(image)
             
         else:
             axes.imshow(labels, cmap = use_cm)
         axes.set_title(title,
                        fontname=cpprefs.get_title_font_name(),
                        fontsize=cpprefs.get_title_font_size())
     if set_lim:
         orig_axes.set_xlim((x0, x1))
         orig_axes.set_ylim((y0, y1))
     figure.canvas.draw()
     panel.Refresh()
 def run(self, workspace):
     stats = [("Image","Objects","Bin # (innermost=1)","Bin count","Fraction","Intensity","COV")]
     d = {}
     for image in self.images:
         for o in self.objects:
             for bin_count_settings in self.bin_counts:
                 stats += \
                 self.do_measurements(workspace,
                                      image.image_name.value,
                                      o.object_name.value,
                                      o.center_object_name.value
                                      if o.center_choice != C_SELF
                                      else None,
                                      o.center_choice.value,
                                      bin_count_settings,
                                      d)
     if workspace.frame is not None:
         images = [d[key][0] for key in d.keys()]
         names = d.keys()
         figure = workspace.create_or_find_figure(title="MeasureObjectRadialDistribution, image cycle #%d"%(
             workspace.measurements.image_set_number),subplots=(1,len(images)))
         figure.figure.clf()
         nimages = len(images)
         shrink = .05
         for i in range(len(images)):
             rect = [shrink + float(i)/float(nimages),
                     .5+shrink,
                     (1.0-2*shrink)/float(nimages),
                     .45*(1.0-2*shrink)]
             axes = figure.figure.add_axes(rect)
             axes.imshow(images[i], matplotlib.cm.Greys_r)
             axes.set_title(names[i],
                            fontname=cpprefs.get_title_font_name(),
                            fontsize=cpprefs.get_title_font_size())
         rect = [0.1,.1,.8,.35]
         axes = figure.figure.add_axes(rect, frameon = False)
         table = axes.table(cellText=stats,
                            colWidths=[1.0/7.0]*7,
                            loc='center',
                            cellLoc='left')
         axes.set_axis_off()
         table.auto_set_font_size(False)
         table.set_fontsize(cpprefs.get_table_font_size())
示例#6
0
 def get_title_font(self):
     return "%s,%f" % (cpprefs.get_title_font_name(),
                       cpprefs.get_title_font_size())
示例#7
0
 def get_title_font(self):
     return "%s,%f"%(cpprefs.get_title_font_name(),
                      cpprefs.get_title_font_size())