Changeset 2516
- Timestamp:
- 29/05/07 08:37:11 (14 years ago)
- Location:
- TI02-CSML/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/csmllibs/csmldataiface.py
r2509 r2516 543 543 self.extractType = 'rawExtract' 544 544 self.extractPrefix = '_rawextract_' 545 546 545 546 547 547 def openFile(self, filename): 548 548 self.file = open(filename, "rb") … … 579 579 # Read and unpack data into a Numeric array. 580 580 self.data = Numeric.array(struct.unpack(format_str, self.file.read())) 581 582 # The order of dimensions in Numeric arrays do not correspond with 583 # the order of dimensions in traditional image files, so we need to 584 # reverse the dimensions before shaping the array. 585 dimensions = map(int, kwargs['dimensions']) 586 dimensions.reverse() 587 self.data.shape = tuple(dimensions) 581 self.data.shape = tuple(map(int, kwargs['dimensions'])) 588 582 589 583 # If numericTransform or fillValue were provided, store them as … … 677 671 self.extractType = 'imageExtract' 678 672 self.extractPrefix = '_imageextract_' 673 674 def image2array(self,im): 675 #Adapted from code by Fredrik Lundh, http://www.pythonware.com 676 #http://effbot.org/zone/pil-numpy.htm 677 if im.mode not in ("L", "F"): 678 raise ValueError, "can only convert single-layer images" 679 if im.mode == "L": 680 a = Numeric.fromstring(im.tostring(), Numeric.UnsignedInt8) 681 else: 682 a = Numeric.fromstring(im.tostring(), Numeric.Float32) 683 a.shape = im.size[1], im.size[0] 684 return a 679 685 680 686 def openFile(self, filename): … … 686 692 def readFile(self, **kwargs): 687 693 # Convert the image to a Numeric array 688 self.data = Numeric.array(self.file.getdata()) 694 695 self.data=self.image2array(self.file) 696 #slower method: 697 #self.data = Numeric.array(self.file.getdata()) 689 698 690 699 # The order of dimensions in Numeric arrays do not correspond with -
TI02-CSML/trunk/setup.py
r2255 r2516 6 6 """ 7 7 8 import ez_setup; 8 import ez_setup;ez_setup.use_setuptools() 9 9 from setuptools import setup, find_packages 10 10 11 11 setup( 12 12 name = 'csml', 13 version = '2.0 ',13 version = '2.0b', 14 14 author = 'Dominic Lowe', 15 15 author_email = 'd.lowe@rl.ac.uk',
Note: See TracChangeset
for help on using the changeset viewer.