Freeman chain code

Freeman chain code algorithm to extract boundaries of objects in a binary image. Help, doc, examples included. + Some bwmorph operators.

252 Downloads

Updated 29 May 2023

From GitHub

View License on GitHub

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Use on binary images only (use imbinarize to binarize your image).
Check the use examples provided in Freeman_chain_code_examples.m to help / inspire you.
Recent update adds some image processing toolbox bwmorph "spare operators" you might recognize (dilate_image, erode_image, image_bw_remove, open_image, close_image), updated examples and images.
image_bw_remove function looks specially interesting to get quickly and all at once your binary image boundaries.
Please rate if it helped you, thanks. ;-)
% Freeman_chain_code : function to extract the contour of a given shape using
% Freeman chain code. For binary images only.
%
% Author & support : nicolas.douillet (at) free.fr, 2005-2023.
%
% Reference
%
% Freeman H, Computer Processing of Line-Drawing Images,
% ACM Computing Surveys, Vol. 6, No.1, 1974, pp57-97.
%
% Inputs
%
% - I : binary (0/1) image where 0 pixels correspond to the black
% background, and 1 pixels correspond to the object(s) / shape(s) to
% segment.
%
% - option_display : either logical, true/false or numeric 1/0.
%
% Outputs
%
% - bound_img : binary (0/1) image of the input image boundaries. size(bound_img) = size(I).
%
% - X0 : cell array of integer vectors of double, the boundaries initial pixels coordinates.
%
% - Code : cell array of integer vectors of double, the boundaries Freeman coding vectors.
%
% - bound_coord : cell array of integer vectors of double, the boundaries pixels coordinates.
%
% Current known limitations
%
% - Only extract the shapes outer boundaries / do not extract one shape inner parts

Cite As

Nicolas Douillet (2023). Freeman chain code (https://github.com/NicolasDouillet/Freeman_chain_code/releases/tag/v3.2), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
3.2

See release notes for this release on GitHub: https://github.com/NicolasDouillet/Freeman_chain_code/releases/tag/v3.2

3.1

See release notes for this release on GitHub: https://github.com/NicolasDouillet/Freeman_chain_code/releases/tag/v3.1

3.0

See release notes for this release on GitHub: https://github.com/NicolasDouillet/Freeman_chain_code/releases/tag/v3.0

2.0

See release notes for this release on GitHub: https://github.com/NicolasDouillet/Freeman_chain_code/releases/tag/v2.0

1.1

See release notes for this release on GitHub: https://github.com/NicolasDouillet/Freeman_chain_code/releases/tag/v1.1

1.0.1

Improve description

1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.