Esempio n. 1
0
 def save_display_as_image(self, workspace, display, image_name):
     '''Convert an ImageJ display to an image and save in the image set
     
     workspace - current workspace
     display - an ImageJ Display
     image_name - save the image in the image set using this name.
     '''
     display_view = display.getActiveView()
     dataset = ij2.wrap_dataset(display_view.getData())
     pixel_data = dataset.get_pixel_data() / IMAGEJ_SCALE
     mask = ij2.create_mask(display)
     image = cpi.Image(pixel_data, mask=mask)
     workspace.image_set.add(image_name, image)
     return pixel_data
Esempio n. 2
0
 def save_display_as_image(self, workspace, display, image_name):
     '''Convert an ImageJ display to an image and save in the image set
     
     workspace - current workspace
     display - an ImageJ Display
     image_name - save the image in the image set using this name.
     '''
     display_view = display.getActiveView()
     dataset = ij2.wrap_dataset(display_view.getData())
     pixel_data = dataset.get_pixel_data() / IMAGEJ_SCALE
     mask = ij2.create_mask(display)
     image = cpi.Image(pixel_data, mask=mask)
     workspace.image_set.add(image_name, image)
     return pixel_data
Esempio n. 3
0
 def test_06_01_get_mask_data(self):
     # Get the overlay data from a display
     #
     display_svc = ij2.get_display_service(self.context)
     overlay_svc = ij2.get_overlay_service(self.context)
     image = np.zeros((30, 30))
     ds = ij2.create_dataset(self.context, image, "Foo")
     display = display_svc.createDisplay("Foo", ds)
     d2 = display_svc.createDisplay("Bar", ij2.create_dataset(self.context, image, "Bar"))
     overlay = J.run_script(
         """var o = new Packages.imagej.data.overlay.RectangleOverlay(context.getContext());
            o.setOrigin(5, 0);
            o.setOrigin(3, 1);
            o.setExtent(6, 0);
            o.setExtent(7, 1);
            o;""", dict(context=self.context))
     overlay_svc.addOverlays(display, J.make_list([overlay]))
     ij2.select_overlay(display.o, overlay)
     mask = ij2.create_mask(display)
     i, j = np.mgrid[0:mask.shape[0], 0:mask.shape[1]]
     np.testing.assert_equal(mask, (j >= 5) & (j < 11) & (i >= 3) & (i < 10))