def get_raw_data(self): '''Get the pixel intensities (i.e. read the image and return as a flex array of integers.)''' from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex assert(len(self.get_detector()) == 1) panel = self.get_detector()[0] size = panel.get_image_size() f = FormatSMVADSC.open_file(self._image_file, 'rb') f.read(self._header_size) if self._header_dictionary['BYTE_ORDER'] == 'big_endian': big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(size[0] * size[1])) image_size = panel.get_image_size() raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data
def read_smv_image(image_file): from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex header_size, header_dictionary = get_smv_header(image_file) f = open(image_file, 'rb') f.read(header_size) if header_dictionary['BYTE_ORDER'] == 'big_endian': big_endian = True else: big_endian = False image_size = (int(header_dictionary['SIZE1']), int(header_dictionary['SIZE2'])) if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(image_size[0] * image_size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(image_size[0] * image_size[1])) raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data
def get_raw_data(self): '''Get the pixel intensities (i.e. read the image and return as a flex array of integers.)''' from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex assert (len(self.get_detector()) == 1) panel = self.get_detector()[0] size = panel.get_image_size() f = FormatSMVNOIR.open_file(self._image_file, 'rb') f.read(self._header_size) if self._header_dictionary['BYTE_ORDER'] == 'big_endian': big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(size[0] * size[1])) image_size = panel.get_image_size() raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data
def get_raw_data(self): '''Get the pixel intensities (i.e. read the image and return as a flex array of integers.)''' from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex f = self.open_file(self._image_file, 'rb') f.read(self._header_size) if self._header_dictionary['BYTE_ORDER'] == 'big_endian': big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(512 * 512)) else: raw_data = read_uint16_bs(streambuf(f), int(512 * 512)) image_size = (512, 512) raw_data.reshape(flex.grid(image_size[1], image_size[0])) # split into separate panels self._raw_data = [] d = self.get_detector() for panel in d: xmin, ymin, xmax, ymax = self.coords[panel.get_name()] self._raw_data.append(raw_data[ymin:ymax, xmin:xmax]) return tuple(self._raw_data)
def get_raw_data(self): '''Get the pixel intensities (i.e. read the image and return as a flex array of integers.)''' from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex f = self.open_file(self._image_file, 'rb') f.read(self._header_size) nx = int(self._header_dictionary['SIZE1']) # number of pixels ny = int(self._header_dictionary['SIZE2']) # number of pixels if self._header_dictionary['BYTE_ORDER'] == 'big_endian': big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(nx * ny)) else: raw_data = read_uint16_bs(streambuf(f), int(nx * ny)) # note that x and y are reversed here raw_data.reshape(flex.grid(ny, nx)) self._raw_data = raw_data return self._raw_data
def get_raw_data(self): """Get the pixel intensities (i.e. read the image and return as a flex array of integers.)""" from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex assert len(self.get_detector()) == 1 image_pedestal = 40 panel = self.get_detector()[0] size = panel.get_image_size() f = FormatSMVADSCSN.open_file(self._image_file, "rb") f.read(self._header_size) if self._header_dictionary["BYTE_ORDER"] == "big_endian": big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(size[0] * size[1])) # apply image pedestal, will result in *negative pixel values* raw_data -= image_pedestal image_size = panel.get_image_size() raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data
def get_raw_data(self): '''Get the pixel intensities (i.e. read the image and return as a flex array of integers.)''' from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex f = self.open_file(self._image_file, 'rb') header_size = int(self.header_dict['HDRBLKS']) * 512 f.read(header_size) # 16 bits per pixel assert int(self.header_dict['NPIXELB'].split()[0]) == 2 nrows = int(self.header_dict['NROWS'].split()[0]) ncols = int(self.header_dict['NCOLS'].split()[0]) if is_big_endian(): raw_data = read_uint16_bs(streambuf(f), nrows * ncols) else: raw_data = read_uint16(streambuf(f), nrows * ncols) image_size = (nrows, ncols) raw_data.reshape(flex.grid(image_size[0], image_size[1])) return raw_data
def get_raw_data(self): """Get the pixel intensities (i.e. read the image and return as a flex array of integers.)""" from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex assert len(self.get_detector()) == 1 image_pedestal = int(self._header_dictionary["IMAGE_PEDESTAL"]) panel = self.get_detector()[0] size = panel.get_image_size() f = FormatSMVADSCSN.open_file(self._image_file, "rb") f.read(self._header_size) if self._header_dictionary["BYTE_ORDER"] == "big_endian": big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(size[0] * size[1])) # apply image pedestal, will result in *negative pixel values* raw_data -= image_pedestal image_size = panel.get_image_size() raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data
def read_smv_image(image_file): from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex header_size, header_dictionary = get_smv_header(image_file) with open(image_file, "rb") as f: f.seek(header_size) if header_dictionary["BYTE_ORDER"] == "big_endian": big_endian = True else: big_endian = False image_size = (int(header_dictionary["SIZE1"]), int(header_dictionary["SIZE2"])) if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(image_size[0] * image_size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(image_size[0] * image_size[1])) raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data
def get_raw_data(self): """Get the pixel intensities (i.e. read the image and return as a flex array of integers.)""" from boost.python import streambuf from dxtbx import read_uint16, read_uint16_bs, is_big_endian from scitbx.array_family import flex assert len(self.get_detector()) == 1 image_pedestal = 1 try: image_pedestal = float(self._header_dictionary["ADC_OFFSET"]) except KeyError: pass panel = self.get_detector()[0] size = panel.get_image_size() f = FormatSMVJHSim.open_file(self._image_file, "rb") f.read(self._header_size) if self._header_dictionary["BYTE_ORDER"] == "big_endian": big_endian = True else: big_endian = False if big_endian == is_big_endian(): raw_data = read_uint16(streambuf(f), int(size[0] * size[1])) else: raw_data = read_uint16_bs(streambuf(f), int(size[0] * size[1])) # apply image pedestal, will result in *negative pixel values* # this is a horrible idea since raw_data is unsigned # see all instances of image_pedestal in dxtbx raw_data -= int(image_pedestal) image_size = panel.get_image_size() raw_data.reshape(flex.grid(image_size[1], image_size[0])) return raw_data