Пример #1
0
    def preprocess_image(self, i):
        downscale = self.downscale
        lab_frame_image = freeimage.read(self.timepoint_list[i].image_path('bf'))
        lab_frame_image = lab_frame_image.astype(numpy.float32)
        height, width = lab_frame_image.shape[:2]

        try:
            metadata = self.timepoint_list[i].position.experiment.metadata
            optocoupler = metadata['optocoupler']
        except KeyError:
            optocoupler = 1
        mode = process_images.get_image_mode(lab_frame_image, optocoupler=optocoupler)

        #### DownSample the image 
        if downscale > 0 and downscale != 1:#and set_name!='train':        
            #t_size = (int(width / downscale), int(height / downscale))  
            shrink_image = pyramid.pyr_down(lab_frame_image, downscale=downscale)
            #shrink_image = numpy.clip(shrink_image, 0, 40000)   
        else:
            shrink_image = lab_frame_image

        shrink_image = shrink_image.astype(numpy.float32)

        ## scale the image pixel value into a trainable range
        # map image image intensities in range (100, 2*mode) to range (0, 2)
        bf = colorize.scale(shrink_image, min=100, max=2*mode, output_max=2)
        # now shift range to (-1, 1)
        bf -= 1
        return bf
Пример #2
0
 def normalized_bf_image(self, i):
     bf = freeimage.read(self.timepoint_list[i].image_path('bf'))
     mode = process_images.get_image_mode(bf, optocoupler=self.timepoint_list.optocoupler(i))
     # map image image intensities in range (100, 2*mode) to range (0, 2)
     bf = colorize.scale(bf, min=100, max=2*mode, output_max=2)
     # now shift range to (-1, 1)
     bf -= 1
     return bf
Пример #3
0
def normalized_bf_image(timepoint):
    """Given a timepoint, return a normalized brightfield image."""
    bf = freeimage.read(timepoint.image_path('bf'))
    mode = process_images.get_image_mode(
        bf, optocoupler=timepoint.position.experiment.metadata['optocoupler'])
    # map image image intensities in range (100, 2*mode) to range (0, 2)
    bf = colorize.scale(bf, min=100, max=2 * mode, output_max=2)
    # now shift range to (-1, 1)
    bf -= 1
    return bf
Пример #4
0
def scale_image(image,
                optocoupler=1,
                new_mode=24000,
                new_max=26000,
                new_min=600,
                gamma=0.72):
    # step 1: make an image that has a modal value of 24000, yielding a known intensity distribution
    noise_floor = 100
    image_mode = process_images.get_image_mode(image, optocoupler=optocoupler)
    image = image.astype(np.float32)
    image -= noise_floor
    image *= (new_mode - noise_floor) / (image_mode - noise_floor)
    image += noise_floor

    # step 2: scale that known distribution down to [0,1] using empirical parameters
    image.clip(min=new_min, max=new_max, out=image)
    image -= new_min
    image /= new_max - new_min
    # now image is in the range [0, 1]
    image **= gamma  # optional nonlinear gamma transform
    return image
Пример #5
0
def preprocess_image(timepoint, downscale):
    img_path = timepoint.image_path('bf')
    lab_frame_image = freeimage.read(img_path)
    lab_frame_image = lab_frame_image.astype(numpy.float32)
    height, width = lab_frame_image.shape[:2]
    objective, optocoupler, magnification, temp = get_metadata(timepoint)

    mode = process_images.get_image_mode(lab_frame_image,
                                         optocoupler=optocoupler)
    #### DownSample the image
    if downscale > 0 and downscale != 1:  #and set_name!='train':
        shrink_image = pyramid.pyr_down(lab_frame_image, downscale=downscale)
        #shrink_image = numpy.clip(shrink_image, 0, 40000)
    else:
        shrink_image = lab_frame_image

    shrink_image = shrink_image.astype(numpy.float32)

    ## scale the image pixel value into a trainable range
    # map image image intensities in range (100, 2*mode) to range (0, 2)
    bf = colorize.scale(shrink_image, min=100, max=2 * mode, output_max=2)
    # now shift range to (-1, 1)
    bf -= 1
    return bf