Problem with sparse colours

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Problem with sparse colours

Post 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();
}
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Problem with sparse colours

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem with sparse colours

Post 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'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply