Changeset 1217 for trunk/GSASIIIO.py
- Timestamp:
- Feb 11, 2014 9:42:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r1216 r1217 267 267 Comments,Data,Npix,Image = GetG2Image(imagefile) 268 268 elif ext == '.png': 269 import scipy.misc 270 Image = scipy.misc.imread(imagefile,flatten=True) 271 Npix = Image.size 272 Comments = ['no metadata'] 273 Data = {'wavelength': 0.1, 'pixelSize': [200, 200], 'distance': 100.0} 274 Data['size'] = list(Image.shape) 275 Data['center'] = [int(i/2) for i in Image.shape] 269 Comments,Data,Npix,Image = GetPNGData(imagefile) 276 270 if not imageOnly: 277 271 EditImageParms(G2frame,Data,Comments,Image,imagefile) … … 501 495 else: 502 496 return head,data,Npix,image 497 498 def GetPNGData(filename,imageOnly=False): 499 '''Read an image in a png format, assumes image is converted from CheMin tif file 500 so default parameters are that machine. 501 ''' 502 import scipy.misc 503 Image = scipy.misc.imread(filename,flatten=True) 504 Npix = Image.size 505 Comments = ['no metadata'] 506 pixy = list(Image.shape) 507 sizexy = [40,40] 508 Data = {'wavelength': 1.78892, 'pixelSize': sizexy, 'distance': 18.0,'size':pixy} 509 Data['center'] = [pixy[0]*sizexy[0]/1000,pixy[1]*sizexy[1]/2000] 510 if imageOnly: 511 return Image.T 512 else: 513 return Comments,Data,Npix,Image.T 503 514 504 515 def GetTifData(filename,imageOnly=False): … … 508 519 ''' 509 520 import struct as st 521 import Image as Im 510 522 import array as ar 511 523 import ReadMarCCDFrame as rmf … … 540 552 NED = int(st.unpack(byteOrd+'h',File.read(2))[0]) 541 553 IFD = {} 554 nSlice = 1 542 555 for ied in range(NED): 543 556 Tag,Type = st.unpack(byteOrd+'Hh',File.read(4)) 544 557 nVal = st.unpack(byteOrd+'i',File.read(4))[0] 558 if DEBUG: print 'Try:',Tag,Type,nVal 545 559 if Type == 1: 546 560 Value = st.unpack(byteOrd+nVal*'b',File.read(nVal)) … … 551 565 x = st.unpack(byteOrd+nVal*'h',File.read(nVal*2)) 552 566 elif Type == 4: 567 if Tag in [273,279]: 568 nSlice = nVal 569 nVal = 1 553 570 Value = st.unpack(byteOrd+nVal*'i',File.read(nVal*4)) 554 571 elif Type == 5: … … 581 598 center = (center[0] != 0 and center[1] != 0) and center or [None,None] 582 599 #print head,tifType,pixy 600 elif nSlice > 1: #CheMin multislice tif file! 601 tifType = 'CheMin' 602 pixy = [40,40] 603 image = np.array(Im.open(filename)) 604 distance = 18.0 605 center = [pixy[0]*sizexy[0]/2000,pixy[1]*sizexy[1]/1000] 606 wavelength = 1.78892 583 607 elif 272 in IFD: 584 608 ifd = IFD[272]
Note: See TracChangeset
for help on using the changeset viewer.