It is not easy to use sgext.
I think the readme of sgext should be update. The example code is:
import sgext
input_filename="/path/to/binary_image.nrrd" # or any format that ITK can read
out_folder="/path/to/output_folder" # or any format that ITK can read
sgext.scripts.thin(input=input_filename,
out_folder=out_folder,
foreground="black",
skel_type="end",
select_type="first",
persistence=2,
visualize=False,
verbose=True)
However, the method thin
accept:
input: BinaryImageType
input binary image.
table_folder: str
Location of the DGtal look-up-tables for simplicity and isthmusicity,
for example simplicity_table26_6.zlib.
These tables are distributed with the sgext package. Use the variable
'sgext.tables_folder'.
Then, my code is:
itkImg = itk.GetImageFromArray(mask)
sgext.scripts.thin(input=itkImg,
table_folder= './',
foreground="black",
skel_type="end",
select_type="first",
persistence=2,
visualize=False,
verbose=True
)
The mask is a numpy matrix (500500400, uint8). And a bug is reported:
TypeError: thin(): incompatible function arguments. The following argument types are supported:
1. (input: itk::SmartPointer<itk::Image<unsigned char,3> >, skel_type: str, select_type: str, tables_folder: str, persistence: int = 0, input_distance_map_image: itk::SmartPointer<itk::Image<float,3> > = None, profile: bool = False, verbose: bool = False, visualize: bool = False) -> itk::SmartPointer<itk::Image<unsigned char,3> >
Invoked with: kwargs: input=<itkImagePython.itkImageUC3; proxy of <Swig Object of type 'itkImageUC3 *' at 0x00000241E1D999F0> >, table_folder='./', foreground='black', skel_type='end', select_type='first', persistence=2, visualize=False, verbose=True