示例#1
0
 def transform(self, images, *args, **kwargs):
     if self.selected:
         if COLOR_IMAGE in images:
             images[COLOR_IMAGE] = self.image_service.linear_scaling(images[COLOR_IMAGE], self.alpha, self.beta)
             images[OUT_IMAGE] = COLOR_IMAGE
         else:
             raise TransformationError("Contrast and brightness transformation requires color image")
     return images
示例#2
0
 def transform(self, images, *args, **kwargs):
     if self.selected:
         if GRAY_IMAGE in images:
             images[OUT_IMAGE] = BIN_IMAGE
             images[BIN_IMAGE] = self.image_service.otsu_binarization(images[GRAY_IMAGE])
         else:
             raise TransformationError("Otsu binarization requires grayscale image")
     return images
 def transform(self, images, *args, **kwargs):
     if self.selected:
         if COLOR_IMAGE in images:
             images[OUT_IMAGE] = COLOR_IMAGE
             images[COLOR_IMAGE] = self.image_service.brightness_equalizer(
                 images[COLOR_IMAGE], self.clip_limit, self.tile_grid_size)
         else:
             raise TransformationError(
                 "Brightness equalizer transformation requires color image")
     return images
示例#4
0
 def transform(self, images, *args, **kwargs):
     if self.selected:
         if COLOR_IMAGE in images:
             images[OUT_IMAGE] = GRAY_IMAGE
             images[GRAY_IMAGE] = self.image_service.bgr_to_gray(
                 images[COLOR_IMAGE])
         else:
             raise TransformationError(
                 "RGB to gray transformation requires color image")
     return images
示例#5
0
    def transform(self, images, *args, **kwargs):
        if self.selected:
            if GRAY_IMAGE in images:
                images[GRAY_IMAGE] = self.image_service.gaussian_blur(
                    images[GRAY_IMAGE], self.kernel)
                images[OUT_IMAGE] = GRAY_IMAGE
            else:
                raise TransformationError(
                    "Gaussian blur requires transformation grayscale image")

        return images
示例#6
0
 def transform(self, images, *args, **kwargs):
     if self.selected:
         if BIN_IMAGE in images:
             images[BIN_IMAGE] = self.image_service.morphology_closing(
                 images[BIN_IMAGE], self.kernel)
             images[OUT_IMAGE] = BIN_IMAGE
         else:
             raise TransformationError(
                 "Morphology - closing transformation requires binary image"
             )
     return images
示例#7
0
 def transform(self, images, *args, **kwargs):
     if self.selected:
         if COLOR_IMAGE in images:
             images[COLOR_IMAGE] = self.image_service.clip_and_rotate(
                 images[COLOR_IMAGE], self.gaussian_blur,
                 (self.lower_h, self.lower_s, self.lower_v),
                 (self.upper_h, self.upper_s, self.upper_v), self.canny_min,
                 self.canny_max)
             images[OUT_IMAGE] = COLOR_IMAGE
             images[CLIPPED_IMAGE] = images[COLOR_IMAGE]
         else:
             raise TransformationError("Clip requires color image")
     return images
示例#8
0
 def gaussian_blur(self, image, kernel=(5, 5)):
     if kernel[0] % 2 == 0 or kernel[1] % 2 == 0:
         raise TransformationError(
             "Gaussian kernel must have odd dimension")
     return cv2.GaussianBlur(image, kernel, 0)