Beispiel #1
0
    def encode_entry(self, entry):
        """
        Return numpy.ndarray
        """
        feature_image_file = entry[0]
        label_image_file = entry[1]

        feature_image = self.encode_PIL_Image(
            image.load_image(feature_image_file))
        label_image = self.encode_PIL_Image(image.load_image(label_image_file))

        return feature_image, label_image
Beispiel #2
0
    def encode_entry(self, entry):
        """
        Return numpy.ndarray
        """
        feature_image_file = entry[0]
        label_image_file = entry[1]

        feature_image = self.encode_PIL_Image(
            image.load_image(feature_image_file))
        label_image = self.encode_PIL_Image(
            image.load_image(label_image_file))

        return feature_image, label_image
Beispiel #3
0
    def encode_entry(self, entry):
        """
        Return numpy.ndarray
        """
        feature_image_file = entry[0]
        label_image_file = entry[1]

        # feature image
        feature_image = self.encode_PIL_Image(
            image.load_image(feature_image_file), self.channel_conversion)

        # label image
        label_image = self.load_label(label_image_file)
        if label_image.getpalette() != self.userdata[COLOR_PALETTE_ATTRIBUTE]:
            raise ValueError("All label images must use the same palette")
        label_image = self.encode_PIL_Image(label_image)

        return feature_image, label_image
Beispiel #4
0
    def encode_entry(self, entry):
        """
        Return numpy.ndarray
        """
        feature_image_file = entry[0]
        label_image_file = entry[1]

        # feature image
        feature_image = self.encode_PIL_Image(
            image.load_image(feature_image_file),
            self.channel_conversion)

        # label image
        label_image = self.load_label(label_image_file)
        if label_image.getpalette() != self.userdata[COLOR_PALETTE_ATTRIBUTE]:
            raise ValueError("All label images must use the same palette")
        label_image = self.encode_PIL_Image(label_image)

        return feature_image, label_image
Beispiel #5
0
    def scale_image(self, filename):
        im = np.array(image.load_image(filename))

        # center crop
        if self.userdata['center_crop_size']:
            crop_size = int(self.userdata['center_crop_size'])
            width, height = im.shape[0:2]
            i = (width // 2) - crop_size // 2
            j = (height // 2) - crop_size // 2
            im = im[i:i + crop_size, j:j + crop_size, :]

        # resize
        if self.userdata['resize']:
            resize = int(self.userdata['resize'])
            im = image.resize_image(im, resize, resize, resize_mode='squash')

        # transpose to CHW
        feature = im.transpose(2, 0, 1)

        return feature
Beispiel #6
0
    def scale_image(self, filename):
        im = np.array(image.load_image(filename))

        # center crop
        if self.userdata['center_crop_size']:
            crop_size = int(self.userdata['center_crop_size'])
            width, height = im.shape[0:2]
            i = (width // 2) - crop_size // 2
            j = (height // 2) - crop_size // 2
            im = im[i:i + crop_size, j:j + crop_size, :]

        # resize
        if self.userdata['resize']:
            resize = int(self.userdata['resize'])
            im = image.resize_image(im, resize, resize, resize_mode='squash')

        # transpose to CHW
        feature = im.transpose(2, 0, 1)

        return feature