[GSAS-II] TIF image import fails with some TIF files

Creuziger, Adam Abel (Fed) adam.creuziger at nist.gov
Tue Jan 12 12:12:38 CST 2021


While importing and manipulating some 2-D detector images from a Bruker system and saved using the python Pillow (PIL) library, I ran into some issues with the GSAS-II failing to read the TIF files.  The problem seemed to be that there was no ’shape’ attribute in the TIF file, but there was a ’size’.  Adding the try/except blocks listed below resolved the issue.

One other note, the TIF reader seems to expect/want the integer based 8 bit files [0 to 255].  Outputting the TIF as a float worked ok on import, but the max/min intensity sliders didn’t permit decimal values. The float data seemed to be 32 bit, so that may be relevant for additional users.  Unfortunately the float TIF format requires values between 1 and 0, so it would be handy to have a way to input the counts to float scale.

in imports/G2img_1TIF.py, lines 84 and 85 were replaced with:

                try:
                    self.Data['size'] = list(self.Image.shape)
                except:
                    self.Data['size'] = list(self.Image.size)
                try:
                    self.Data['center'] = [int(i/2) for i in self.Image.shape]
                except:
                    self.Data['center'] = [int(i/2) for i in self.Image.size]

in GSASIIIO.py, line 245 was replaced with:

    try:
        h,w = Image.shape[:2]
    except:
        h,w = Image.size[:2]

____________________________
Dr. Adam Creuziger
National Institute of Standards and Technology (NIST)
Gaithersburg, MD USA 20899.8553
Office 301-975-6015
adam.creuziger at nist.gov<mailto:adam.creuziger at nist.gov>

Visiting Research Affiliate Faculty, Metallurgical and Materials Engineering. Colorado School of Mines




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.aps.anl.gov/pipermail/gsas-ii/attachments/20210112/1f808321/attachment.html>


More information about the GSAS-II mailing list