Page 1 of 1

Optimal repetly operations

Posted: 2012-01-18T09:32:39-07:00
by trebol-a
Hi all,

I need to make ( in bash ) a big picture (about 5000 pixel) with a list of small circles (like a spacial dispersion graphical).
How is the optimal and fastest method for this if i need set about 6000-7000 circles over a white background of 5000x5000 pixels?

This?
for n in $(seq 1 5000); do convert -draw 'circle $px,$py $px, ($py-$radius)' results.jpg; done
Or something like?
comand="convert "
for n in $(seq 1 5000); do circles+=" -draw 'circle $px,$py $px, ($py-$radius)'"; done
comand+=$circles
comand+=" results.jpg"
$comand
this last option bash say "unable to open image `120,20' " (where 120 is $px and 20 $py)

Regards

Re: Optimal repetly operations

Posted: 2012-01-25T20:55:57-07:00
by anthony
Saming all the draw commands into a "mgv" file and then using -draw "@file.mgv" should work quite fast.
This has the advantage that the circles can also be positioned at sub-pixel locations (floating point positions using pixel coordinates)
Note by using draw paths, with relative coordinates, you can draw circles (or other symbol shapes) by just specifying the center point only, followed by a fixed string.. no need to do any calculations yourself...
http://www.imagemagick.org/Usage/draw/#symbol_drawing
and relative circle drawing see..
http://www.imagemagick.org/Usage/draw/#circles

The other way for integer positions is create a "txt" file listing single white pixel at each point you want. You do not need to decalre the other pixels in a "txt" image, but just set a default -background color.
See http://www.imagemagick.org/Usage/files/#txt

Code: Select all

# ImageMagick pixel enumeration: 5000,5000,255,rgb
100,2431: (255,255,255)
375,933: ( 255,255,255)
...

Code: Select all

convert -background black pixels.txt .....
That image can then be filtered using a 'morphology' or 'convolve' operator to convert each pixel into a circle or other symbol.
Examples of this is in is Draw Symbols Other Methods...
http://www.imagemagick.org/Usage/draw/#symbol_alts

NOTE only draw methods can do sub-pixel positioning.