plotting many lines (>10^5 lines)

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
Posts: 1
Joined: 2012-02-01T15:49:53-07:00
Authentication code: 8675308

plotting many lines (>10^5 lines)

Post by scshaner » 2012-02-01T16:10:52-07:00

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))

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;


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

	return 0;

User avatar
Site Admin
Posts: 10996
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2012-02-01T17:10:10-07:00

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.

Post Reply