How to use the fabio.edfimage 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 / pyFAI / test / profileDistortionCSR.py View on Github external
# working with halfccd spline
#    x, y = numpy.ogrid[:2048, :2048]
#    grid = numpy.logical_or(x % 100 == 0, y % 100 == 0).astype(numpy.float32) + numpy.ones((2048, 2048), numpy.float32)
#    det = detectors.FReLoN("frelon.spline")


    print det, det.max_shape
    disLUT = _distortion.Distortion(det)
    print disLUT
    lut = disLUT.calc_LUT_size()
    print disLUT.lut_size
    print lut.mean()

    disLUT.calc_LUT()
    outLUT = disLUT.correct(grid)
    fabio.edfimage.edfimage(data=outLUT.astype("float32")).write("test_correct_LUT.edf")

    print("*"*50)


    print det, det.max_shape
    disCSR = _distortionCSR.Distortion(det,foo=64)
    print disCSR
    lut = disCSR.calc_LUT_size()
    print disCSR.lut_size
    print lut.mean()

    disCSR.calc_LUT()
    outCSR = disCSR.correct(grid)
    fabio.edfimage.edfimage(data=outCSR.astype("float32")).write("test_correct_CSR.edf")

    print("*"*50)
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:]))
github silx-kit / pyFAI / sandbox / profileDistortionCSR.py View on Github external
disCSR.setDevice()
    outCSRocl = disCSR.correct(grid)
    fabio.edfimage.edfimage(data=outCSRocl.astype("float32")).write("test_correct_CSR.edf")

    print("*"*50)

    print(det, det.max_shape)
    disLUTpy = distortion.Distortion(det)
    print(disLUTpy)
    lut = disLUTpy.calc_LUT_size()
    print(disLUTpy.lut_size)
    print(lut.mean())

    disLUTpy.calc_LUT()
    outLUTpy = disLUTpy.correct(grid)
    fabio.edfimage.edfimage(data=outLUTpy.astype("float32")).write("test_correct_LUT.edf")

    print("*"*50)

#    x, y = numpy.ogrid[:2048, :2048]
#    grid = numpy.logical_or(x % 100 == 0, y % 100 == 0)
#    det = detectors.FReLoN("frelon.spline")
#    print( det, det.max_shape)
#    dis = Distortion(det)
#    print(dis
#    lut = dis.calc_LUT_size()
#    print(dis.lut_size
#    print("LUT mean & max", lut.mean(), lut.max()
#    dis.calc_LUT()
#    out = dis.correct(grid)
#    fabio.edfimage.edfimage(data=out.astype("float32")).write("test2048.edf")
    import pylab
github silx-kit / pyFAI / pyFAI-src / azimuthalIntegrator.py View on Github external
"rot2": str(self._rot2),
                  "rot3": str(self._rot3),
                  "chi_min": str(dim2.min()),
                  "chi_max": str(dim2.max()),
                  dim1_unit + "_min": str(dim1.min()),
                  dim1_unit + "_max": str(dim1.max()),
                  "pixelX": str(self.pixel2), # this is not a bug ... most people expect dim1 to be X
                  "pixelY": str(self.pixel1), # this is not a bug ... most people expect dim2 to be Y
                  }
        if self.splineFile:
            header["spline"] = str(self.splineFile)
        f2d = self.getFit2D()
        for key in f2d:
            header["key"] = f2d[key]
        try:
            fabio.edfimage.edfimage(data=I.astype("float32"),
                                    header=header).write(filename)
        except IOError:
            logger.error("IOError while writing %s" % filename)
github silx-kit / pyFAI / pyFAI / app / drawmask.py View on Github external
def saveAndClose(self):
        if self.__outputFile is None:
            filename = qt.QFileDialog.getSaveFileName(self)
            if isinstance(filename, tuple):
                # Compatibility with PyQt5
                filename = filename[0]

            if filename is None or filename == "":
                # Cancel the closing of the application
                return
            self.__outputFile = filename

        mask = self.getSelectionMask()
        fabio.edfimage.edfimage(data=mask).write(self.__outputFile)
        print("Mask-file saved into %s" % (self.__outputFile))
        self.close()