def _extract_image_pixels(self, flex_image, frame, trusted_range): """Extract pixels from a single image Params: image The image from which to extract the pixels frame The frame number of the current image trusted_range The trusted range of pixel values Returns: The list of selected pixels """ from scitbx.array_family import flex from dials.algorithms.peak_finding import flex_vec3_int from dials.algorithms.peak_finding import mean_sdev_filter import numpy from time import time # Calculate the threshold threshold = self._calculate_threshold(flex_image, trusted_range) # Extract the pixel indices image = flex_image.as_numpy_array() height, width = image.shape image.shape = -1 index = numpy.where(image >= threshold)[0] # Create the array of pixel coordinates z = [frame] * len(index) y = map(int, index // width) x = map(int, index % width) coords = flex_vec3_int(zip(x, y, z)) # Get the array of pixel intensities intensity = flex.int(image[index]) # Return the pixel values return coords, intensity
def _extract_image_pixels(self, flex_image, frame, trusted_range): '''Extract pixels from a single image Params: image The image from which to extract the pixels frame The frame number of the current image trusted_range The trusted range of pixel values Returns: The list of selected pixels ''' from scitbx.array_family import flex from dials.algorithms.peak_finding import flex_vec3_int from dials.algorithms.peak_finding import mean_sdev_filter import numpy from time import time # Calculate the threshold threshold = self._calculate_threshold(flex_image, trusted_range) # Extract the pixel indices image = flex_image.as_numpy_array() height, width = image.shape image.shape = -1 index = numpy.where(image >= threshold)[0] # Create the array of pixel coordinates z = [frame] * len(index) y = map(int, index // width) x = map(int, index % width) coords = flex_vec3_int(zip(x, y, z)) # Get the array of pixel intensities intensity = flex.int(image[index]) # Return the pixel values return coords, intensity
def _extract_pixels(self, sweep): """Extract the pixels from the sweep Params: sweep The sweep object Returns: The list of selected pixels """ from dials.util.command_line import ProgressBar from scitbx.array_family import flex from dials.algorithms.peak_finding import flex_vec3_int # Initialise the pixel arrays coords = flex_vec3_int() intensity = flex.int() # Get the start index and trusted range from the sweep start = sweep.get_array_range()[0] trusted_range = sweep.get_detector().get_trusted_range() # Loop through all the images in the sweep and extract the pixels # from each of the images progress = ProgressBar() for frame, image in enumerate(sweep): c, i = self._extract_image_pixels(image, frame + start, trusted_range) coords.extend(c) intensity.extend(i) progress.update(100.0 * float(frame + 1) / len(sweep)) progress.finished() # Reuturn the pixel values return coords, intensity
def _extract_pixels(self, sweep): '''Extract the pixels from the sweep Params: sweep The sweep object Returns: The list of selected pixels ''' from dials.util.command_line import ProgressBar from scitbx.array_family import flex from dials.algorithms.peak_finding import flex_vec3_int # Initialise the pixel arrays coords = flex_vec3_int() intensity = flex.int() # Get the start index and trusted range from the sweep start = sweep.get_array_range()[0] trusted_range = sweep.get_detector().get_trusted_range() # Loop through all the images in the sweep and extract the pixels # from each of the images progress = ProgressBar() for frame, image in enumerate(sweep): c, i = self._extract_image_pixels(image, frame + start, trusted_range) coords.extend(c) intensity.extend(i) progress.update(100.0 * float(frame + 1) / len(sweep)) progress.finished() # Reuturn the pixel values return coords, intensity