Page 1 of 1

Mapping IM commands , reduce red channell for 'red eye'

Posted: 2006-11-29T15:03:40-07:00
by monsters
Hi there, this works dandy in ImageMagick CLI

convert red-eye.jpg -region 24x14+72+115 -channel red -modulate 100,70 output.jpg


I can't for the life of me figure out how to duplicate this in MagickWand

Any help appreciated.

Posted: 2006-11-29T17:07:47-07:00
by el_supremo
[edit]Oooops. I meant to reply to your post in the MagickWand forum. Oh well.

I think this does what you wanted :-)
I'd be interested if anyone has a better/alternate method.

Pete

Code: Select all

	MagickWand *magick_wand = NULL,*region_wand = NULL;
	int dx,dy,x,y;

	MagickWandGenesis();

	magick_wand = NewMagickWand();
	MagickReadImage(magick_wand,"magick.jpg");

	// Specify the region's (x,y) coordinate
	x = 115;
	y = 25;
	// and its width and height
	dx = 40;
	dy = 40;
	// and extract it
	region_wand = MagickGetImageRegion(magick_wand,dx,dy,x,y);
	// Modulate the region
	MagickModulateImage(region_wand,50,70,0);
	// and now copy the red channel back
	MagickCompositeImageChannel(magick_wand,RedChannel,region_wand,CopyCompositeOp,x,y);

	MagickWriteImage(magick_wand,"magick_red_eye.jpg");

	/* Clean up */
	if(magick_wand)magick_wand = DestroyMagickWand(magick_wand);
	if(region_wand)region_wand = DestroyMagickWand(region_wand);
	MagickWandTerminus();

Hmm

Posted: 2006-11-30T16:38:45-07:00
by monsters
well, that technique is a start, i end up with some very green images..

currently trying to figure out
MagickFxImage , which it would seem nobody has ever used before.. ever. 8)

Doesn't seem to matter what i pass in, it doesn't do anything..


I was tring fx strings, like this
MagickFxImage( $region_wand, "u.r /2",MW_RedChannel );

but quickly realised it did nothing, and neither does this
MagickFxImage( $region_wand, "xxxxxxxxxxxxxxxxxxxxxx",MW_RedChannel );



MagickWand is really, really cryptic, and almost not documented at all... I'm pretty surprised by all that..

Posted: 2006-11-30T18:25:12-07:00
by magick
Did you try
  • fx_wand = MagickFxImageChannel( $region_wand, "u /2", MW_RedChannel );
MagickFxImageChannel() returns a wand and leaves the original image sequence untouched.

i did.

Posted: 2006-11-30T22:09:47-07:00
by monsters
It's great to see an admin involved!!

I did, it would seem , to me, that the magickwand api returns a wand, but that the php implementation of it actually returns a magickwand boolean (true | false )

I've found this discrepency in other areas as well..

I will double check though.

Posted: 2006-12-11T10:50:48-07:00
by monsters
I ended up solving this by doing a pixel iteration and replacing the red pixels with non red pixels, i can't post the actual formula due to my NDA's and such, but the formula was not a complicated one.

I never could get the fx commands to work.