Changeset 9d4e502 in sasview for DataLoader
- Timestamp:
- Apr 1, 2009 1:55:03 PM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- de5c813
- Parents:
- 1328e03
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/tiff_reader.py
rded92e4 r9d4e502 16 16 import math, logging, os 17 17 import numpy 18 from DataLoader.data_info import Image2D18 from DataLoader.data_info import Data2D 19 19 20 20 class Reader: … … 51 51 52 52 # Instantiate data object 53 output = Image2D()53 output = Data2D() 54 54 output.filename = os.path.basename(filename) 55 55 … … 59 59 except : 60 60 raise RuntimeError,"cannot open %s"%(filename) 61 data = im.load()61 predata = im.load() 62 62 63 63 x_range = im.size[0] … … 65 65 66 66 # Initiazed the output data object 67 output. image= numpy.zeros([y_range,x_range])68 67 output.data = numpy.zeros([y_range,x_range]) 68 output.err_data = numpy.zeros([y_range,x_range]) 69 69 # Initialize 70 70 x_vals = [] … … 83 83 84 84 try: 85 if data[i_x,i_y].__class__.__name__=="tuple":85 if predata[i_x,i_y].__class__.__name__=="tuple": 86 86 87 if len(data[i_x,i_y]) == 3: 88 R,G,B= data[i_x,i_y] 89 #Converting to L Mode: uses the ITU-R 601-2 luma transform. 90 value = float(R * 299/1000 + G * 587/1000 + B * 114/1000) 87 if len(predata[i_x,i_y]) == 3: 88 R,G,B= predata[i_x,i_y] 89 elif len(predata[i_x,i_y]) == 4: 90 R,G,B,I = predata[i_x,i_y] 91 #Converting to L Mode: uses the ITU-R 601-2 luma transform. 92 value = float(R * 299/1000 + G * 587/1000 + B * 114/1000) 91 93 92 elif len(data[i_x,i_y]) == 4:93 R,G,B,I = data[i_x,i_y]94 #Take only I95 value = float(R * 299/1000 + G * 587/1000 + B * 114/1000)+float(I)96 94 else: 97 95 #Take it as Intensity 98 value = float( data[i_x,i_y])96 value = float(predata[i_x,i_y]) 99 97 except: 100 98 logging.error("tiff_reader: had to skip a non-float point") … … 102 100 103 101 104 output. image[y_range-i_y-1,i_x] = value102 output.data[y_range-i_y-1,i_x] = value 105 103 106 104 output.xbins = x_range … … 109 107 output.y_bins = y_vals 110 108 output.xmin = 0 111 output.xmax = x_range 109 output.xmax = x_range-1 112 110 output.ymin = 0 113 output.ymax = y_range 111 output.ymax = y_range-1 114 112 115 113 return output 116 114 117 118
Note: See TracChangeset
for help on using the changeset viewer.