Exemplo n.º 1
0
 def save_one_image(self):
     self.save_one_image_button.setEnabled(False)
     f, fext = self.QFD.getSaveFileName(self, 'Save image', self.last_dir,
                                        "Image Files (*.tif)")
     if f == self.last_dir:
         fname = os.path.join(f, "image-{:>04}.tif".format(self.nim))
         self.nim += 1
     else:
         fname = f + '.tif'
     self.last_dir = os.path.dirname(fname)
     tmp = False
     if self.live_preview_thread.live_on == True:
         self.live_off_func()
         tmp = True
     if self.camera_model_label.text() != 'Dummy camera':
         if self.camera.state == 'recording':
             self.camera.stop_recording()
         self.camera['trigger_source'].stash().join()
         self.camera.trigger_source = self.camera.trigger_sources.SOFTWARE
     self.set_camera_params()
     try:
         if self.camera_model_label.text() != 'Dummy camera':
             with self.camera.recording():
                 self.camera.trigger()
                 im = self.camera.grab()
         else:
             im = self.camera.grab()
     finally:
         write_tiff(fname, im)
         if self.camera_model_label.text() != 'Dummy camera':
             self.camera['trigger_source'].restore().join()
         self.save_one_image_button.setEnabled(True)
     if tmp == True:
         self.live_on_func()
Exemplo n.º 2
0
def RR(mws, odir, fname):
    im = read_image(fname).astype(np.float32)
    N = im.shape[0]
    tmp = np.sum(im, 0) / N
    tmp = medf(tmp, (mws, ))
    tmp = np.array([
        tmp,
    ] * N)
    im -= tmp
    filt_sin_name = os.path.join(odir, os.path.split(fname)[1])
    write_tiff(filt_sin_name, (im).astype(np.float32))
Exemplo n.º 3
0
    def start_command(program, image):
        """
        Create a tmp file for dumping the *image* and use *program*
        to open that image. Use *writer* for writing the iamge to the disk.
        """
        from concert.storage import write_tiff

        tmp_file = tempfile.mkstemp()[1]
        try:
            full_path = write_tiff(tmp_file, image)
            with Popen([program, full_path]) as process:
                process.wait()
        finally:
            os.remove(full_path)
            LOG.debug('Temporary file removed')
Exemplo n.º 4
0
def RR_sort(mws, odir, fname):
    filt_sin_name = os.path.join(odir, os.path.split(fname)[1])
    write_tiff(
        filt_sin_name,
        remove_stripe_based_sorting(read_image(fname).astype(np.float32),
                                    mws).astype(np.float32))
Exemplo n.º 5
0
def RR_wide_sort(mws, mws2, snr, odir, fname):
    filt_sin_name = os.path.join(odir, os.path.split(fname)[1])
    im = read_image(fname).astype(np.float32)
    im = remove_large_stripe(im, snr, mws2)
    im = remove_stripe_based_sorting(im, mws)
    write_tiff(filt_sin_name, im.astype(np.float32))