neodroidvision.data.synthesis.conversion.mnist.json_generation.mask_json_utilities.MaskJsonUtils

class neodroidvision.data.synthesis.conversion.mnist.json_generation.mask_json_utilities.MaskJsonUtils(output_dir)[source]

Bases: object

Creates a JSON definition file for image masks.

__init__(output_dir)[source]

Initializes the class. Args: output_dir: the directory where the definition file will be saved

Methods

__init__(output_dir)

Initializes the class.

add_category(category, super_category)

Adds a new category to the set of the corresponding super_category Args: category: e.g.

add_mask(image_path, mask_path, color_categories)

Takes an image path, its corresponding mask path, and its color categories, and adds it to the appropriate dictionaries Args: image_path: the relative path to the image, e.g. './images/00000001.png' mask_path: the relative path to the mask image, e.g. './masks/00000001.png' color_categories: the legend of color categories, for this particular mask, represented as a rgb-color keyed dictionary of category names and their super categories. (the color category associations are not assumed to be consistent across images) Returns: True if successful, False if the image was already in the dictionary.

get_masks()

Gets all masks that have been added

get_super_categories()

Gets the dictionary of super categories for each category in a JSON serializable format Returns: A dictionary of lists of categories keyed on super_category

write_masks_to_json()

Writes all masks and color categories to the output file path as JSON

add_category(category, super_category)[source]

Adds a new category to the set of the corresponding super_category Args: category: e.g. ‘eagle’ super_category: e.g. ‘bird’ Returns: True if successful, False if the category was already in the dictionary

add_mask(image_path, mask_path, color_categories)[source]

Takes an image path, its corresponding mask path, and its color categories, and adds it to the appropriate dictionaries Args: image_path: the relative path to the image, e.g. ‘./images/00000001.png’ mask_path: the relative path to the mask image, e.g. ‘./masks/00000001.png’ color_categories: the legend of color categories, for this particular mask,

represented as a rgb-color keyed dictionary of category names and their super categories. (the color category associations are not assumed to be consistent across images)

Returns: True if successful, False if the image was already in the dictionary

get_masks()[source]

Gets all masks that have been added

get_super_categories()[source]

Gets the dictionary of super categories for each category in a JSON serializable format Returns: A dictionary of lists of categories keyed on super_category

write_masks_to_json()[source]

Writes all masks and color categories to the output file path as JSON