want to label parts of an image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

want to label parts of an image

Post 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 ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: want to label parts of an image

Post 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.
snibgo's IM pages: im.snibgo.com
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: want to label parts of an image

Post by manit »

sorry, wasn't online for long time.
You have explained nicely.
Implementing that will be complex and tedious.
Post Reply