Пример #1
0
def LoadImageBatch(path, img_format):
    """
    Generic function to be used in multi-threaded batch read for input images.
    """
    image = misc.imread(path)
    if image.shape[2] == 4:
        image = image[:, :, 0:3]

    if img_format == "HEDab":
        dec = deconv.Deconvolution()
        dec.params['image_type'] = 'HEDab'

        np_img = np.array(image)
        dec_img = dec.colorDeconv(np_img[:, :, :3])

        image = dec_img.astype('uint8')

    elif img_format == "HE":
        dec = deconv.Deconvolution()
        dec.params['image_type'] = 'HEDab'

        np_img = np.array(image)
        dec_img = dec.colorDeconv(np_img[:, :, :3])

        image = dec_img.astype('uint8')

    return image
Пример #2
0
    def LoadImage(self, path):
        """
        Loads one single input image with certain image format.
        This image format can be 'RGB', 'HEDab' and 'HE'.

        """

        if not hasattr(self, "img_format"):
            self.img_format = "RGB"

        image = misc.imread(path)
        if image.shape[2] == 4:
            image = image[:, :, 0:3]

        if self.img_format == "HEDab":
            dec = deconv.Deconvolution()
            dec.params['image_type'] = 'HEDab'

            np_img = np.array(image)
            dec_img = dec.colorDeconv(np_img[:, :, :3])

            image = dec_img.astype('uint8')

        elif self.img_format == "HE":
            dec = deconv.Deconvolution()
            dec.params['image_type'] = 'HEDab'

            np_img = np.array(image)
            dec_img = dec.colorDeconv(np_img[:, :, :3])

            image = dec_img.astype('uint8')

        return image
Пример #3
0
    def _apply_(self, *image):
        res = ()
        n_img = 0
        for img in image:
            if n_img == 0:
                ### transform image into HE
                dec = deconv.Deconvolution()
                dec.params['image_type'] = 'HEDab'

                np_img = np.array(img)
                dec_img = dec.colorDeconv(np_img)
                #pdb.set_trace()
                dec_img = dec_img.astype('uint8')
                ### perturbe each channel H, E, Dab
                for i in range(3):
                    k_i = self.params['k'][i]
                    b_i = self.params['b'][i]
                    val = np.max(dec_img[:, :, i])
                    dec_img[:, :, i] = GreyValuePerturbation(dec_img[:, :, i],
                                                             k_i,
                                                             b_i,
                                                             MIN=0,
                                                             MAX=255)
                    val -= np.max(dec_img[:, :, i])
                    dec_img[:, :, i] += val
                sub_res = dec.colorDeconvHE(dec_img).astype('uint8')

                ### Have to implement deconvolution of the deconvolution

            else:
                sub_res = img

            res += (sub_res, )
            n_img += 1
        return res