Page 1 of 1

want to label parts of an image

Posted: 2019-07-02T04:52:22-07:00
by manit
hi,
I am using
$ display --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
on 64bit ubuntu OS
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial

My aim is to take a text file as input which contains the coordinates and corresponding label .
Then I will draw a circle at that coordinate say (x,y) . Then I want to draw a line from that point towards a label outside the image.
Say, image is 300x300 so I will take 500x500 canvas and paste the image in center .
the 200 pixel empty space around borders will contain text label .

Currently , I am doing the following creating a circle and drawing a line vertically to bottom of image where text gets appended.
So, image height increases after each text label addition.
The drawback is that too many vertical lines spoil the image.

My idea is to draw a text label and paste it along the border closest among four borders.
is there a script available to label images in such a manner ?

Re: want to label parts of an image

Posted: 2019-07-02T05:32:03-07:00
by snibgo
manit wrote:is there a script available to label images in such a manner ?
I don't have one.

For each coordinate that needs a label, you could choose the closest border point and place the label there, as you say.

A couple of further complications:

1. You don't want labels to overlap each other.
2. For clarity, you don't want lines to cross each other.

For condition (1), you might imagine the label area outside the main image to be divided into a number of slots. Maintain an array that specifies whether a slot is used. Then the task for each coordinate is to find the closest slot that is not already used.

Condition (2) is more complex.

Re: want to label parts of an image

Posted: 2019-10-09T08:48:16-07:00
by manit
sorry, wasn't online for long time.
You have explained nicely.
Implementing that will be complex and tedious.