Example #1
0
    def test_merge(self):
        """ Tests merge_screen function """
        # Test if overview image changes after inserted optical and sem image
        md = {
            model.MD_DESCRIPTION: "green dye",
            model.MD_BPP: 12,
            model.MD_BINNING: (1, 1),  # px, px
            model.MD_PIXEL_SIZE: (1e-6, 1e-6),  # m/px
            model.MD_POS: (13.7e-3, -30e-3),  # m
            model.MD_EXP_TIME: 1,  # s
            model.MD_IN_WL: (600e-9, 620e-9),  # m
            model.MD_OUT_WL: (620e-9, 650e-9),  # m
            model.MD_USER_TINT: (0, 0, 255),  # RGB (blue)
            model.MD_ROTATION: 0.1,  # rad
            model.MD_SHEAR: 0,
            model.MD_DIMS: "YXC"
        }

        opt = model.DataArray(200 * numpy.ones((10, 10, 3), dtype=numpy.uint8), md)
        sem = model.DataArray(10 * numpy.ones((10, 10, 3), dtype=numpy.uint8), md)
        merged = merge_screen(opt, sem)
        # Test if at least one element of ovv image is different from original images
        # self.assertEqual(merged.shape, (10, 10, 3))
        self.assertTrue(numpy.all(merged >= opt))
        self.assertTrue(numpy.any(merged != opt))
        self.assertTrue(numpy.all(merged >= sem))
        self.assertTrue(numpy.any(merged != sem))

        # Two very bright images should give a complete white
        opt = model.DataArray(250 * numpy.ones((10, 10, 3), dtype=numpy.uint8), md)
        sem = model.DataArray(250 * numpy.ones((10, 10, 3), dtype=numpy.uint8), md)
        merged = merge_screen(opt, sem)
        # Test if at least one element of ovv image is different from original images
        # self.assertEqual(merged.shape, (10, 10, 3))
        self.assertTrue(numpy.all(merged == 255))
Example #2
0
    def _update_ovv(self):
        """ Update the overview image based on the sub images. """
        # Merge all overview images: Overview = (bkg opt + opt) + (bkg_sem + sem)
        opt = merge_screen(self._bkg_opt, self.im_opt)
        sem = merge_screen(self._bkg_sem, self.im_sem)
        self.ovv_im = merge_screen(opt, sem)

        # Update display
        self.upd_stream.update(self.ovv_im)
        self.canvas.fit_view_to_content()
Example #3
0
    def test_merge(self):
        """ Tests merge_screen function """
        # Test if overview image changes after inserted optical and sem image
        md = {
            model.MD_DESCRIPTION: "green dye",
            model.MD_BPP: 12,
            model.MD_BINNING: (1, 1),  # px, px
            model.MD_PIXEL_SIZE: (1e-6, 1e-6),  # m/px
            model.MD_POS: (13.7e-3, -30e-3),  # m
            model.MD_EXP_TIME: 1,  # s
            model.MD_IN_WL: (600e-9, 620e-9),  # m
            model.MD_OUT_WL: (620e-9, 650e-9),  # m
            model.MD_USER_TINT: (0, 0, 255),  # RGB (blue)
            model.MD_ROTATION: 0.1,  # rad
            model.MD_SHEAR: 0,
            model.MD_DIMS: "YXC"
        }

        opt = model.DataArray(200 * numpy.ones((10, 10, 3), dtype=numpy.uint8),
                              md)
        sem = model.DataArray(10 * numpy.ones((10, 10, 3), dtype=numpy.uint8),
                              md)
        merged = merge_screen(opt, sem)
        # Test if at least one element of ovv image is different from original images
        # self.assertEqual(merged.shape, (10, 10, 3))
        self.assertTrue(numpy.all(merged >= opt))
        self.assertTrue(numpy.any(merged != opt))
        self.assertTrue(numpy.all(merged >= sem))
        self.assertTrue(numpy.any(merged != sem))

        # Two very bright images should give a complete white
        opt = model.DataArray(250 * numpy.ones((10, 10, 3), dtype=numpy.uint8),
                              md)
        sem = model.DataArray(250 * numpy.ones((10, 10, 3), dtype=numpy.uint8),
                              md)
        merged = merge_screen(opt, sem)
        # Test if at least one element of ovv image is different from original images
        # self.assertEqual(merged.shape, (10, 10, 3))
        self.assertTrue(numpy.all(merged == 255))
Example #4
0
    def _update_ovv(self):
        """ Update the overview image with the currently active stream. """
        if self.curr_s and self.curr_s.image.value is not None:
            s = self.curr_s
            img = s.image.value
            if isinstance(s, acqstream.OpticalStream):
                self.im_opt = insert_tile_to_image(img, self.im_opt)
            elif isinstance(s, acqstream.EMStream):
                self.im_sem = insert_tile_to_image(img, self.im_sem)
            else:
                logging.info("%s not added to overview image as it's not optical nor EM", s)

            # Merge optical and sem overview images
            self.ovv_im = merge_screen(self.im_opt, self.im_sem)

            # Update display
            self.upd_stream.update(self.ovv_im)
            self.canvas.fit_view_to_content()
Example #5
0
    def _update_ovv(self):
        """ Update the overview image with the currently active stream. """
        if self.curr_s and self.curr_s.image.value is not None:
            s = self.curr_s
            img = s.image.value
            if isinstance(s, acqstream.OpticalStream):
                self.im_opt = insert_tile_to_image(img, self.im_opt)
            elif isinstance(s, acqstream.EMStream):
                self.im_sem = insert_tile_to_image(img, self.im_sem)
            else:
                logging.info("%s not added to overview image as it's not optical nor EM", s)

            # Merge optical and sem overview images
            self.ovv_im = merge_screen(self.im_opt, self.im_sem)

            # Update display
            self.upd_stream.update(self.ovv_im)
            self.canvas.fit_view_to_content()