Page 1 of 1
Posted: 2006-09-17T19:11:47-07:00
by anthony
What exactly does dividing the color channel by 'tones' do for you?
Or is yoru algorthim incomplete?
As for your problem. I suggest you follow the words of the Computer Science immortal...
Use the source Luke
IM modifies images and image colors all over the place. For example look at
"threshold.c" for simplier example where the colors are thresholded to a given level.
I myself am working on this file, so some things may be a little messy at this moment.
Posted: 2006-09-17T22:27:27-07:00
by anthony
Their is quite a few functions like this already in IM core. The technique is called posterization, and if you look in wand/mogrify.c and look at what -posterize calls you will find the function it uses. (It is called PosterizeImage(), and is in "magick/quantize.c", probably with all the other simular functions)
Alturnatives including calling what the -map function calls with a pre-defined set of colors,
calling the function -colors uses to just reduce the image the best set of colors (and then calls the same map function) OR wait a bit and let me finish the new OrderedPosterizeImage() function in "threshold.c"
That last will not only reduce each channel to a specified number of 'levels' but dither the colors between those levels to generate a large number of psuedo-levels using an ordered dither pattern.
Basically, why re-invent the wheel when you have a vast range of wheels of all sorts already present

Posted: 2006-09-17T22:32:03-07:00
by anthony
Look at my update above, I wasn't finished when you replaied

Posted: 2006-09-17T23:31:31-07:00
by anthony
Flip => vertical mirror image.
Well looking at FlipImage() in "transform.c", it looks like it does some wierd things with indexes on a clone of image. The more I look the wierder it gets, even though it is rather small.
The very next function FlopImage() or normal mirror, looks like a straght copy of pixels from on image its clone.
Posted: 2006-09-18T16:42:27-07:00
by anthony
Sorry, I am not sure. My coding in IM takes existing code then modify it to do what I want. The only other things I have done is to call functions like CompositeImage() and CropImage() to further modify the images.
Sorry I am not that familar with the code, still learning it myself. Most of my work is with the command line usage, I try to avoid low level coding, except to improve command line handling.
The pixel modification however does not look like other code I have seen, but then I have only dealt with IM Core.
Posted: 2006-09-18T20:46:16-07:00
by anthony
You forgot that q->red are floating point, not interger. and such dividiing, then multiplying
by the same value will only have overflow floating point error effects.
Divide the value, floor() it, then multiply it again.
Posted: 2006-09-18T21:09:39-07:00
by anthony
Have you had ANY output change at all?
Posted: 2006-09-18T21:39:09-07:00
by anthony
Then the problem is not in that section, but in how you are trying to save the changes back into an image or a clone of the image. Backoff and check the rest of the code, compare it to the other code in the sources.