How to use the fabio.tifimage.tifimage function in fabio

To help you get started, we’ve selected a few fabio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github silx-kit / fabio / test / testmccdimage.py View on Github external
def setUp(self):
        """
        create an image 
        """
        self.image = os.path.join(UtilsTest.tempdir, "tifimagewrite_test0000.tif")
        self.imdata = numpy.zeros((24, 24), numpy.uint16)
        self.imdata[12:14, 15:17] = 42
        obj = tifimage(self.imdata, {})
        obj.write(self.image)
github ronpandolfi / Xi-cam / xicam / plugins / viewerRMC.py View on Github external
else:
                self.write_path += '_centered.tif'
            self.write_path_sample = self.write_path

            img = tifimage.tifimage(np.rot90((self.edited_image.astype(float) /
                                              self.edited_image.max() * 2 ** 16).astype(np.int16)))
        else:
            self.write_path = self.mask_path

            if self.write_path.endswith('.tif'):
                self.write_path = self.write_path[:-4] + '_centered.tif'
            else:
                self.write_path += '_centered.tif'
            self.write_path_mask = self.write_path

            img = tifimage.tifimage(np.rot90(self.edited_image.astype(float)))




        img.write(self.write_path)

        if sample:
            self.edited_view.setImage(self.edited_image)

            box = self.drawCameraLocation(self.edited_view,new_center)
            self.drawROI(lowleft_corner_x,lowleft_corner_y,xdim,ydim,'r', box)
            self.drawROI(0,0,self.new_dim,self.new_dim, 'b', box)

            # this is a temporary fix for a problem: pushing a button changes tab back to first
            self.image_holder.setCurrentIndex(1)
github ronpandolfi / Xi-cam / xicam / plugins / viewerRMC.py View on Github external
lowleft_corner_x = int(new_center[0]-self.cameraLocation[0])
        lowleft_corner_y = int(new_center[1]-self.cameraLocation[1])

        self.edited_image[lowleft_corner_x:lowleft_corner_x+xdim,lowleft_corner_y: lowleft_corner_y+ydim] = image

        # save image
        if sample:
            self.write_path = self.path

            if self.write_path.endswith('.tif'):
                self.write_path = self.write_path[:-4] + '_centered.tif'
            else:
                self.write_path += '_centered.tif'
            self.write_path_sample = self.write_path

            img = tifimage.tifimage(np.rot90((self.edited_image.astype(float) /
                                              self.edited_image.max() * 2 ** 16).astype(np.int16)))
        else:
            self.write_path = self.mask_path

            if self.write_path.endswith('.tif'):
                self.write_path = self.write_path[:-4] + '_centered.tif'
            else:
                self.write_path += '_centered.tif'
            self.write_path_mask = self.write_path

            img = tifimage.tifimage(np.rot90(self.edited_image.astype(float)))




        img.write(self.write_path)
github ronpandolfi / Xi-cam / pipeline / writer.py View on Github external
def writeimage(image, path, headers=None, suffix='',ext=None):
    if headers is None: headers = dict()
    if ext is None: ext = os.path.splitext(path)[-1]

    path = ''.join(os.path.splitext(path)[:-1]) + suffix + ext
    if notexitsoroverwrite(path):
        if ext.lower() == '.edf':
            fabimg = edfimage.edfimage(np.rot90(image), header=headers)
            fabimg.write(path)
        elif ext.lower() == '.tif':
            fabimg = tifimage.tifimage(np.rot90((image.astype(float)/image.max()*2**16).astype(np.int16)), header=headers)
            fabimg.write(path)
        elif ext.lower() == '.png':
            raise NotImplementedError
        elif ext.lower() == '.jpg':
            scipy.misc.imsave(path,np.rot90(image))

    else:
        return False
    return True
github silx-kit / fabio / fabio / app / viewer.py View on Github external
def convert_and_write(self, fname, format_, data, header):
        if format_ == '*.bin':
            out = open(fname, mode="wb")
            out.write(data.tostring())
            out.close()
            return
        elif format_ == '*.marccd':
            out = fabio.marccdimage.marccdimage(data=data, header=header)
        elif format_ == '*.edf':
            out = fabio.edfimage.edfimage(data=data, header=header)
        elif format_ == '*.tiff':
            out = fabio.tifimage.tifimage(data=data, header=header)
        elif format_ == '*.cbf':
            out = fabio.cbfimage.cbfimage(data=data, header=header)
        elif format_ in ['*.mar3450', '*.mar2300']:
            data = self.padd_mar(data, format_)
            out = fabio.mar345image.mar345image(data=data, header=header)
        elif format_ == '*.img':
            out = fabio.OXDimage.OXDimage(data=data, header=header)
        elif format_ == '*.sfrm':
            out = fabio.brukerimage.brukerimage(data=data, header=header)
        else:
            raise Warning("Unknown format: %s" % format_)
        template = 'Writing file %s to %s format, please wait...'
        self.statusBar().showMessage(template % (fname, format_[2:]))
        self.log.appendPlainText('Writing file %s to %s format' % (fname, format_[2:]))
        qt.QCoreApplication.processEvents()
        out.write(fname)
github ronpandolfi / Xi-cam / pipeline / formats.py View on Github external
def read(self, filename, frame=None):
        for tiff in tiffclasses:
            if hasattr(tiff,'validate'): # check which class preferably based on the validate staticmethod
                try:
                    tiff.validate(filename, frame)
                except Exception as ex:
                    continue
            try: # if there isn't one, try to read with this class
                return xicamtiffimage._instantiate_read(tiff,filename,frame)
            except Exception as ex:
                continue

        # if custom classes fail, use built-in class
        return xicamtiffimage._instantiate_read(fabio.tifimage.tifimage, filename, frame)