Skip to content

An implementation of the Moore Neighborhood algorithm used to trace the contours of a given image and output a JSON (or plist) file

License

Notifications You must be signed in to change notification settings

markckim/Contour_Tracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contour_Tracing

This is an implementation of the Moore Neighborhood algorithm used to trace the contours of a given image and output a JSON (or plist) file of the resulting pixel coordinates. If an image is made up of more than one body, the coordinate data for each body will be stored in a separate array. Coordinate data is of the form @"{x,y}" and can be parsed from an iOS application using CGPointFromString.

Example JSON data for an image made up of two rectangular bodies:

[["{0,0}","{0,1}","{1,1}","{1,0}"],["{3,2}","{5,2}","{5,3}","{3,3}"]].

In order to use the program, follow these steps:

debug_constants.h

// select highest alpha value considered "clear" (0 thru 255)
#define ALPHA_THRESHOLD 100

// select image format
#define IMAGE_FORMAT @"png"

// select @"json" or @"plist"
#define FILE_TYPE_TO_RETURN @"json"

// select destination for your data
#define DESTINATION_FOLDER @"/Users/markkim/Desktop/test_tile_data/"

// select images (note: add images to project before compiling)
#define SPRITE_NAMES @[@"cloud", @"alien"]

Cloud Demo

Alien Demo

Sample images taken from http://kenney.nl/

About

An implementation of the Moore Neighborhood algorithm used to trace the contours of a given image and output a JSON (or plist) file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published