spawn_ground_truth()

home > kero > Documentation

Given a folder of images and a tag folder containing the same images, marked with white color, RGB=(255,255,255), this function creates a clone of the folder and a folder of its ground truth images based on the tag folder.

kero.ImageProcessing.photoBox.py

class GreyScaleWorkShop:
  def spawn_ground_truth(self,this_folder, tag_folder,starting_label,
        order_name="img",
        tag_name="img",
        check_missing_mode=False,
        rotate_angle_set=None,
        thresh=254)
    return

 

this_folder String. The name of the folder with images.
tag_folder String. The name of the folder with images. If each image in the tag_folder has a corresponding image of the same name and type, then the rotated image clone and ground truth images will be created and relabelled accordingly.
starting_label Integer. The sequence of numbers will start with this integer.
order_name String. The clone of this_folder will be relabelled with prefix specified by this string.

Default value =”img”

tag_name String. The clone of tag_folder will be relabelled with prefix specified by this string.

Default value =”img”

check_missing_mode Boolean. If True, cloning process of the folders are not performed. The file names of images in this_folder that do not have the corresponding images in the tag_folder will be printed.

Default value =False

rotate_angle_set List of float. Each float is a value in degree with which an image is rotated.

Default value =None

thresh Integer, from 0 to 255. This specifies the RGB values below which the ground truth color is treated converted to black, RGB=(0,0,0) and otherwise white, RGB=(255,255,255).

For example, if the value is set to 244, a pixel with (255,254,246) is converted to white since 244<255,254 and 246 while a pixel with (20,40,120) is converted to black.

Default value = 254

Example usage 1

Download the example here and put them in the working directory under the folder /bb.

import kero.ImageProcessing.photoBox as kip

this_folder = "bb\\Butterflies"
tag_folder =  "bb\\Butterflies_canvas"

gsw=kip.GreyScaleWorkShop()
rotate_angle_set = [0,30,60,90,120,150,180] # None
gsw.spawn_ground_truth(this_folder, tag_folder,1, check_missing_mode=False,rotate_angle_set=rotate_angle_set)

The _canvas folder (top-middle) marks out the butterfly with white colored marker. The ground truth is produced as shown in the top-right.

gtspawn.JPG

Given a folder of images and a tag folder containing the same images, marked with white color, RGB=(255,255,255), this function creates a clone of the folder and a folder of its ground truth images based on the tag folder.

kero.ImageProcessing.photoBox.py

class GreyScaleWorkShop:
  def spawn_ground_truth(self,this_folder, tag_folder,starting_label,
        order_name="img",
        tag_name="img",
        check_missing_mode=False,
        rotate_angle_set=None,
        thresh=254)
    return

 

this_folder String. The name of the folder with images.
tag_folder String. The name of the folder with images. If each image in the tag_folder has a corresponding image of the same name and type, then the rotated image clone and ground truth images will be created and relabelled accordingly.
starting_label Integer. The sequence of numbers will start with this integer.
order_name String. The clone of this_folder will be relabelled with prefix specified by this string.

Default value =”img”

tag_name String. The clone of tag_folder will be relabelled with prefix specified by this string.

Default value =”img”

check_missing_mode Boolean. If True, cloning process of the folders are not performed. The file names of images in this_folder that do not have the corresponding images in the tag_folder will be printed.

Default value =False

rotate_angle_set List of float. Each float is a value in degree with which an image is rotated.

Default value =None

thresh Integer, from 0 to 255. This specifies the RGB values below which the ground truth color is treated converted to black, RGB=(0,0,0) and otherwise white, RGB=(255,255,255).

For example, if the value is set to 244, a pixel with (255,254,246) is converted to white since 244<255,254 and 246 while a pixel with (20,40,120) is converted to black.

Default value = 254

Example usage 1

Download the example here and put them in the working directory under the folder /bb.

import kero.ImageProcessing.photoBox as kip

this_folder = "bb\\Butterflies"
tag_folder =  "bb\\Butterflies_canvas"

gsw=kip.GreyScaleWorkShop()
rotate_angle_set = [0,30,60,90,120,150,180] # None
gsw.spawn_ground_truth(this_folder, tag_folder,1, check_missing_mode=False,rotate_angle_set=rotate_angle_set)

The _canvas folder (top-middle) marks out the butterfly with white colored marker. The ground truth is produced as shown in the top-right.

gtspawn.JPG

kero version: 0.5.1 and above