read_chc#

ktch.io.read_chc(file_path, as_frame=False, validate=True, as_coordinates=True)[source]#

Read chain code (.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.

as_framebool, default=False

If True, return pandas.DataFrame. Otherwise, return numpy.ndarray.

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.

as_coordinatesbool, default=True

If True, convert chain codes to 2D coordinates. If False, return the raw chain code values.

Returns:
chain_codeslist of np.ndarray or pd.DataFrame

Chain codes or coordinates.