I have a single dimensional array with 8 values. I want to create a grayscale image with those values. The image consist of a square with provided width and length. inside that square i want to produce circles with array values. The values from the array will be the radius of the circles. I need a grayscale image of that circle. Any help???
Asked
Active
Viewed 359 times
2
-
Do you mean you want 8 concentric circles based on 8 radii and the centres are all in the middle of the square? What is grey - the background? The circle perimeters? – Mark Setchell Aug 14 '14 at 10:22
-
Yes, 8 concentric circles based on the radii and centers are all in the middle of the square. Gray color is for circle perimeters. The size of the circle varies according to the values. When the size of the circles increases, i need variation in the gray color according to the increasing factor, that is radius of the circle. – Rohit Rajagopal Aug 14 '14 at 10:50
1 Answers
1
You can use ImageMagick for this, either directly from the commandline or from C/C++, Perl, Python, PHP etc.
Start with convert
to get a white square 100pixels by 100pixels.
convert -size 100x100 xc:white circles.jpg
Change colour or file extension as you wish, e.g.
convert -size 200x200 xc:black circles.gif
Now add two circles with centre 50,50
convert -size 100x100 xc:white \
-draw "circle 50,50,60,50" \
-draw "circle 50,50,70,50" \
circles.jpg
The \
is just a line continuation.
Back at my desk now.... so, here is a command:
#!/bin/bash
convert -size 400x400 xc:white -fill transparent \
-stroke gray90 -draw "circle 200,200,260,200" \
-stroke gray80 -draw "circle 200,200,280,200" \
-stroke gray70 -draw "circle 200,200,300,200" \
-stroke gray60 -draw "circle 200,200,320,200" \
-stroke gray50 -draw "circle 200,200,340,200" \
-stroke gray40 -draw "circle 200,200,360,200" \
-stroke gray30 -draw "circle 200,200,380,200" \
-stroke gray20 -draw "circle 200,200,400,200" \
circles.jpg
and the result:
Maybe you can execute it in Java with:
Runtime.exec(...)

Mark Setchell
- 191,897
- 31
- 273
- 432
-
-
Maybe add a Java tag to your question... See http://stackoverflow.com/questions/5150503/image-magick-java – Mark Setchell Aug 14 '14 at 14:00