Page 1 of 1

plotting many lines (>10^5 lines)

Posted: 2012-02-01T16:10:52-07:00
by scshaner
I want to use Magick++ to plot many lines (> 10^5 lines) at one time. The two plotting methods listed in the Magick++ documentation are:

1) drawing lines one at a time (e.g. image.draw( DrawableRectangle(200,200, 270,170)) )
2) drawing lines by using a linked list of Drawable opjects:
std::list<Magick::Drawable> drawList
drawList.push_back(DrawableRectangle(200,100, 270,170))
image.draw(drawList)

Are there any faster methods of plotting many lines at one time? Perhaps by plotting them "on the fly" and never saving the start and end coordinates? As I increase my line count about 10^4 it starts to take many seconds to plot from a linked list. I have included some code that plots a few hundred lines. This takes a few seconds to plot. I hope to find a method that plots upwards on 10^5 lines in only a few seconds. Any suggestions are much appreciated!

Code: Select all

#include "Magick++.h"
#include <math.h>

using namespace Magick;

int main(){

	Image image( Geometry(600,600), Color("white"));
	std::list<Drawable> drawList;

	drawList.push_back(DrawableStrokeColor("black"));
	drawList.push_back(DrawableStrokeWidth(1));

	for (int i=0;i<601; i += 30){
		for (int j = 600; j > -1; j -= 30){
			drawList.push_back(DrawableLine(i,0,j,600));
                       // can these lines be plotted on the fly within the for loop without creating a DrawableLine object?
		}
	}

	image.draw(drawList);
	image.write("track_prac.tiff");
	return 0;
}

Re: plotting many lines (>10^5 lines)

Posted: 2012-02-01T17:10:10-07:00
by magick
The best performance may come from drawing lines from a path which can render all in in operation rather than multiple operations when drawing a line. You may get some speed-up if you use a recent version of ImageMagick on a multi-core system. Modern releases spread the computation over all the cores on your system in parallel. Otherwise, you may need to use some other API for drawing your lines. We have not spent much time on performance issues in the drawing subsystem.