Description
This REST API can manage source data as
- a PNG image (as BASE64 string)
- a PNG image file
and requires a match color and an optional set of options and returns
- the outlines (JSON data) of all areas filled with the match color. The single contour consists of two polylines as a sequence of x, y points, one for the external contour and one for the possible internal contour of each area identified in the image
- a sample png image with the matching pattern filled with the blue color, the outer polyline in red color and the inner polyline in the green color
The API is freely usable 24 hours a day with the only limitation of 100000 characters for the source BASE64 image and of 2 MegaBytes if the source data is a png image.
API address
JSON POST request at:
- tracecontour.com/outlines (BASE64 String)
- tracecontour.com/outlines_image (PNG IMAGE FILE)
Inputs parameters
- png_base64_image: PNG image decoded as a BASE64 string prefixed with 'data: image / png; base64,'
- png_image: PNG image file
- match_color: color of match
- match_not_color: color of no match (allows the inverse of the previous input)
- options: hash of options
You can ask for match_color OR match_not_color not both two
The following block of text identifies an image that can be sent to the api
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QgRERUGkbrRzAAAADdJREFUOMtj/P//PwO5gImBAsACoRgZGUnSBnEvCxqfGAC3iSJnj2oe1TxcNbNg5hXiAeOAlSQAVHYMKlCsaXkAAAAASUVORK5CYII=
Options
- versus: (a | o) Contour scanning mode, counterclockwise or clockwise
- compress: hash with output coordinate compression mode
- linear: (activated with true) omits the points that are included in a segment.
- uniq: (activated with true) omits any duplicate coordinates in the context of the same contour
- visvalingam: activated with the tolerance parameter. Activate the visvalingam algorithm (see Wikipedia) by tolerance parameter.
By default versus is 'a' and the visvalingam tolernce is 10. An example option
{ versus: 'o',
compress: {
visvalingam: {tolerance: 1.5},
uniq: true,
linear: true
}
}
Try with Curl with Base64
curl -v -H "Accept: application/json" -X POST -d "png_base64_image=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QgRERUGkbrRzAAAADdJREFUOMtj/P//PwO5gImBAsACoRgZGUnSBnEvCxqfGAC3iSJnj2oe1TxcNbNg5hXiAeOAlSQAVHYMKlCsaXkAAAAASUVORK5CYII=" -d "match_color=0" -d "options[compress][linear]=true" http://tracecontour.com/outlines &> /dev/stdout
Try with curl, send a PNG image and obtain the sample png one
curl -v -H "Accept: application/json" -X POST -F "png_image=@PATH_OF_YOUR_IMAGE_ON_DISK" -F "match_not_color=0" -F "options[compress][linear]=true" -F "options[compress][visvalingam]=true" -o output.png http://tracecontour.com/outlines_image
THE SOFTWARE-API IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE-API OR THE USE OR OTHER DEALINGS IN THE SOFTWARE-API.