source: trunk/imports/G2img_CheMin.py @ 2068

Last change on this file since 2068 was 2068, checked in by toby, 8 years ago

cleanup image reader documetation

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2014-12-27 11:14:59 -0600 (Sat, 27 Dec 2014) $
4# $Author: $
5# $Revision: $
6# $URL: $
7# $Id: $
8########### SVN repository information ###################
9'''
10*Module G2img_png: png image file*
11---------------------------------------
12
13Routine to read an image in .png (Portable Network Graphics) format.
14For now, the only known use of this is with converted Mars Rover (CheMin)
15tif files, so default parameters are for that.
16
17'''
18
19import sys
20import os
21import GSASIIIO as G2IO
22import GSASIIpath
23GSASIIpath.SetVersionNumber("$Revision: $")
24class png_ReaderClass(G2IO.ImportImage):
25    '''Reads standard PNG images; parameters are set to those of the
26    Mars Rover (CheMin) diffractometer.
27    '''
28    def __init__(self):
29        super(self.__class__,self).__init__( # fancy way to self-reference
30            extensionlist=('.png',),
31            strictExtension=True,
32            formatName = 'PNG image',
33            longFormatName = 'PNG image from CheMin'
34            )
35
36    def ContentsValidator(self, filepointer):
37        '''no test at this time
38        '''
39        return True
40       
41    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
42        '''Reads using standard scipy PNG reader
43        '''
44        import scipy.misc
45        self.Image = scipy.misc.imread(filename,flatten=True)
46        self.Npix = self.Image.size
47        if self.Npix == 0:
48            return False
49        if ParentFrame:
50            self.Comments = ['no metadata']
51            pixy = list(self.Image.shape)
52            sizexy = [40,40]
53            self.Data = {'wavelength': 1.78892, 'pixelSize': sizexy, 'distance': 18.0,'size':pixy}
54            self.Data['center'] = [pixy[0]*sizexy[0]/1000,pixy[1]*sizexy[1]/2000]
55            G2IO.EditImageParms(ParentFrame,self.Data,self.Comments,self.Image,filename)
56        self.LoadImage(ParentFrame,filename)
57        return True
Note: See TracBrowser for help on using the repository browser.