Page 1 of 1

Problem with sparse colours

Posted: 2008-12-19T10:49:42-07:00
by el_supremo
I tried implementing Anthony's examples of sparse colours with MagickWand.
The program works fine when doing his first Voronoi example:

Image

But if I just change VoronoiColorInterpolate to ShepardsColorInterpolate in the program, recompile and run it again, I get this:
Image

I'm using IM 6.4.6 2008-12-01 Q8 both for compiling and command line tests. The Shephards example works on the command line.

Am I doing something wrong or is this a bug?

Pete

Code: Select all

#include <windows.h>

#include <wand/magick_wand.h>

void test_wand(LPTSTR lpCmdLine)
{
	MagickWand *mw = NULL;
	double l_doubles[] = {	
		30,10, 255, 0, 0,	// red
		10,80, 0, 0, 255,	// blue
		70,60, 0,128,0,		// lime
		80,20, 255,255,0	// yellow
	};

	MagickWandGenesis();

	mw  = NewMagickWand();
	MagickSetSize(mw,100,100);
	MagickReadImage(mw,"xc:");

	if(!MagickSparseColorImage(mw,RedChannel|GreenChannel|BlueChannel,
				ShepardsColorInterpolate,
				sizeof(l_doubles)/sizeof(double),
				l_doubles)
		) {
		MessageBox(NULL,"Failed","",MB_OK);
	}
	MagickWriteImage(mw,"sparse_s.png");

	DestroyMagickWand(mw);
   MagickWandTerminus();
}

Re: Problem with sparse colours

Posted: 2008-12-19T17:55:32-07:00
by el_supremo
Solved. I hadn't normalized the colours! They should be specified like this:

Code: Select all

   double l_doubles[] = {   
      30,10, 1, 0, 0,   // red
      10,80, 0, 0, 1,   // blue
      70,60, 0, 1, 0,   // lime [lime is rgb(0,255,0) not rgb(0,128,0)]
      80,20, 1, 1, 0    // yellow
   };
Pete

Re: Problem with sparse colours

Posted: 2009-04-29T19:44:15-07:00
by anthony
The reason I use 'lime' is that within IM 'green' is declared to be SVG green which is half bright-green or RGB(0,128,0).

You can see the color choice that IM has to deal with in this command...

Code: Select all

convert -list color | grep green
As you can see SVG colors have a higher priority than X11 or XPM color definitions.

Fred Weinhaus on the other hand like to use 'green1' in his examples to get a perfect RGB green.

It is a pain that 'green' is not a pure RGB 'green' or even a X-windows 'green' color, but the SVG half-bright 'green'. That is 'green' is more like what 'navy' is for 'blue'.