write_chc#

ktch.io.write_chc(file_path, chain_codes, sample_names=None, xs=None, ys=None, area_per_pixels=None, area_pixels_values=None, validate=True)[source]#

Write chain code to .chc file.

Chain codes represent 2D contours using directional codes from 0 to 7:

3 2 1 4 * 0 5 6 7

The chain code file format is: [Sample name] [X] [Y] [Area (mm2) per pixel] [Area (pixels)] [Chain code] -1

Parameters:
file_pathstr

Path to the chain code file.

chain_codeslist of np.ndarray or np.ndarray

Chain codes with values from 0 to 7 representing directions.

sample_nameslist of str or str, optional

Sample names.

xslist of float or float, optional

X coordinates.

yslist of float or float, optional

Y coordinates.

area_per_pixelslist of float or float, optional

Area (mm2) per pixel.

area_pixels_valueslist of int or int, optional

Area in pixels.

validatebool, default=True

If True, validate that chain code values are between 0 and 7. Set to False to skip validation for legacy files that may contain other values.