CSemanticSegmentationTask¶
- class ikomia.dataprocess.pydataprocess.CSemanticSegmentationTask¶
Base class for semantic segmentatio task in Computer Vision. It consists in labelling each pixel of input image with a class. Common outputs for such task are graylevel mask and color labelled image for visualization. It defines a task with the following properties:
Inputs:
image (
CImageIO)graphics (
CGraphicsInput)
Outputs:
image IO (
CImageIO): by default source image is forwarded.semantic segmentation IO (
CSemanticSegmentationIO)
Derived from
C2dImageTask.Import
from ikomia.dataprocess import CSemanticSegmentationTask
Methods
__init__(arg1)__init__( (object)self) -> None :
get_names(self)Get class names.
get_results(self)Get semantic segmentation results as a
CSemanticSegmentationIOinstance.get_image_with_mask(self)Get a visualization image composed by original input image and colored segmentation mask.
get_image_with_graphics(self)Get visualization image where all extracted information are embedded (graphics items).
Get a visualization image composed by original input image, colored segmentation mask and embedded graphics (outlines of connected components).
read_class_names(self, path)Populate class names from the given text file (one line per class).
set_colors(self, colors)Set colors associated with class names.
set_names(self, names)Set class names.
set_mask(self, mask)Set the segmentation mask computed from the input image.
emit_add_sub_progress_steps(self, count)emit_output_changed(self)emit_step_progress(self)See
emit_step_progress().Overridden methods
end_task_run(self)See
end_task_run().Inherited methods
add_input(self, input)Add new input to the task.
add_output(self, output)Add new output to the task.
apply_graphics_mask(self, origin, processed, ...)Apply the mask generated from graphics to the result image so that only masked areas seems to be processed.
apply_graphics_mask_to_binary(self, origin, ...)Apply the mask generated from graphics to the binary source image.
begin_task_run(self)See
begin_task_run().create_input_graphics_mask(self, index, ...)Generate a binary mask image from the task graphics input at the specified index.
create_graphics_mask(self, width, height, ...)Generate a binary mask image from the given graphics input object.
execute_actions(self, action)Method called when a specific action is requested from the associated widget (see
emit_send_process_action()).forward_input_image(self, input_index, ...)Forward input image at position input_index to output at position output_index.
get_elapsed_time(self)Get the time of the last execution in milliseconds.
get_graphics_mask(self, index)Get the binary mask generated from graphics input at position index.
get_input(self, index)Get input at position index.
get_input_count(self)Get the number of inputs.
get_input_data_type(self, index)Get input data type at position index.
get_inputs(self)Get the whole list of inputs.
get_output(self, index)Get output at position index.
get_output_count(self)Get the number of outputs.
get_output_data_type(self, index)Get output data type at position index.
get_outputs(self)Get the whole list of outputs.
get_parameters(self)Get values of task parameters.
get_progress_steps(self)See
get_progress_steps().global_input_changed(self, is_new_sequence)graphics_changed(self)See
graphics_changed().is_graphics_changed_listening(self)Check whether the task is listening to graphics changed event.
is_mask_available(self, index)Check whether a binary mask from graphics input is available at position index.
parameters_modified(self)Notify that the task parameters have changed.
remove_input(self, index)Remove input at the given position.
run(self)See
run().set_action_flag(self, action, is_enable)Enable or disable the given action.
set_active(self, is_active)See
set_active().set_input(self, input, index)Set input at position index with the given one.
set_input_data_type(self, data_type, index)Set the data type for the input at position index.
set_inputs(self, inputs)Set the whole list of inputs with the given one.
set_output(self, output, index)Set output at position index with the given one.
set_output_color_map(self, index, ...)Bind a display color map to an image output.
set_output_data_type(self, data_type, index)Set the data type for the output at position index.
set_outputs(self, outputs)Set the whole list of outputs with the given one.
set_parameters(self, values)Set values of task parameters.
stop(self)See
stop().update_static_outputs(self)Determine output data type automatically from input data types.
Attributes
nameTask name (must be unique)
typeMain purpose or data type on which the task is dedicated to.
Details
- __init__((object)arg1) None¶
- __init__( (object)self) -> None :
Default constructor
- __init__( (object)self, (str)name) -> None :
Construct CSemanticSegmentationTask object with the given name.
Args:
name (str): task name, must be unique
- get_names((CSemanticSegmentationTask)self) object :¶
Get class names. Call
read_class_names()to populate names from text file.- Returns:
class names
- Return type:
str list
- get_results((CSemanticSegmentationTask)self) CSemanticSegmentationIO :¶
Get semantic segmentation results as a
CSemanticSegmentationIOinstance.- Returns:
semantic segmentation data
- Return type:
- get_image_with_mask((CSemanticSegmentationTask)self) object :¶
Get a visualization image composed by original input image and colored segmentation mask. A transparency factor is applied to see both information.
- Returns:
color mask image
- Return type:
2D numpy array (3 channels)
- get_image_with_graphics((CSemanticSegmentationTask)self) object :¶
Get visualization image where all extracted information are embedded (graphics items).
- Returns:
visualization image
- Return type:
2D Numpy array
- get_image_with_mask_and_graphics((CSemanticSegmentationTask)self) object :¶
Get a visualization image composed by original input image, colored segmentation mask and embedded graphics (outlines of connected components). A transparency factor is applied between original image and mask.
- Returns:
visualization image
- Return type:
2D numpy array (3 channels)
- read_class_names((CSemanticSegmentationTask)self, (str)path) None :¶
Populate class names from the given text file (one line per class).
- Parameters:
path (str) – path to class names definition file
- set_colors((CSemanticSegmentationTask)self, (object)colors) None :¶
Set colors associated with class names. The given list must have the same size as names list. If not provided, random colors are generated while populating the name list (
read_class_names()).- Parameters:
list (colors (list of) – r, g, b integer values in range [0, 255])
- set_names((CSemanticSegmentationTask)self, (object)names) None :¶
Set class names. The function generate associated random colors if none is defined.
- Parameters:
names (list of str)
- set_mask((CSemanticSegmentationTask)self, (object)mask) None :¶
Set the segmentation mask computed from the input image.
- Parameters:
mask (2D - 1 channel numpy array) – segmentation mask
- emit_add_sub_progress_steps((CSemanticSegmentationTask)self, (int)count) None :¶
- emit_graphics_context_changed((CSemanticSegmentationTask)self) None :¶
- emit_output_changed((CSemanticSegmentationTask)self) None :¶
- emit_step_progress((CSemanticSegmentationTask)self) None :¶
See
emit_step_progress().
- end_task_run((CSemanticSegmentationTask)self) None :¶
See
end_task_run().end_task_run( (CSemanticSegmentationTask)self) -> None