Page 2 of 2

Re: IM really needs this feature

Posted: 2014-06-01T12:15:38-07:00
by snibgo
See http://www.imagemagick.org/script/color.php . But you can just use "rgb(58.194%%,30.5%%,31%%)".

Re: IM really needs this feature

Posted: 2014-06-01T12:40:45-07:00
by VanGog
Thanks now it works. So the only thing what could be improved in the -fuzz is to
have possibility to specify more colors
e.g

Code: Select all

convert test.png -colorspace HSL -fuzz 15%% -fill Black +opaque "rgb(%avgH1%%%,%avgS1%%%,%avgL1%%%),rgb(%avgH2%%%,%avgS2%%%,%avgL2%%%)" -colorspace sRGB result_mask.png
It would also solve the missing of wrapping in HSL model.

Re: IM really needs this feature

Posted: 2014-06-01T12:57:02-07:00
by fmw42

Code: Select all

convert test.png -colorspace HSL -fuzz 15%% -fill Black +opaque "rgb(%avgH1%%%,%avgS1%%%,%avgL1%%%),rgb(%avgH2%%%,%avgS2%%%,%avgL2%%%)" -colorspace sRGB result_mask.png
Is it really valid it specify two values for +opaque? I never heard of that feature! If so, is it really finding a fuzz amount around each value and replacing everything not in those two ranges with black?

Re: IM really needs this feature

Posted: 2014-06-01T13:44:40-07:00
by VanGog
Maybe it could be better written like so:

Code: Select all

convert test.png -colorspace HSL -fuzz 15%% -fill Black +opaque "rgb(%avgH1%%%,%avgS1%%%,%avgL1%%%)||rgb(%avgH2%%%,%avgS2%%%,%avgL2%%%)" -colorspace sRGB result_mask.png
I think this would either need new function
instead of IsColorSimilar to use AreColorsSimilar which could recieve more colors in argument. Or just edit the IsColorSimilar function. The algorithm should find out if the color is in range of one of the colors. If both colors are out of range so it would be like they are not in the fuzz tolerance. The idea is simple, but harder to explain because colorspaces are my weakness - I am not good on mathematics. But I know it must work. It's basicly that you process every pixel and test it for multiple conditions.

Re: IM really needs this feature

Posted: 2014-06-01T14:04:31-07:00
by fmw42
VanGog wrote:Maybe it could be better written like so:

Code: Select all

convert test.png -colorspace HSL -fuzz 15%% -fill Black +opaque "rgb(%avgH1%%%,%avgS1%%%,%avgL1%%%)||rgb(%avgH2%%%,%avgS2%%%,%avgL2%%%)" -colorspace sRGB result_mask.png
I think this would either need new function
instead of IsColorSimilar to use AreColorsSimilar which could recieve more colors in argument. Or just edit the IsColorSimilar function. The algorithm should find out if the color is in range of one of the colors. If both colors are out of range so it would be like they are not in the fuzz tolerance. The idea is simple, but harder to explain because colorspaces are my weakness - I am not good on mathematics. But I know it must work. It's basicly that you process every pixel and test it for multiple conditions.

That is why I keep suggesting my 1D color lut using -fx to create the lut. You can build any combination of colors and comparisons.

Re: IM really needs this feature

Posted: 2014-06-17T01:27:07-07:00
by VanGog
I'd like to create my own little program, which could do similar thing as I described here. Based on specialized HSB definitions I could generate masks.

I would like to ask ImageMagick programmers where can I find the blur and level function in IM source? Possibly also function which joins images e.g. you have a grid of 3x3 image same size and want to join them. Because I would like to include these features in my program.

Re: IM really needs this feature

Posted: 2014-06-17T02:06:00-07:00
by snibgo
I'm not a programmer, but:

effect.c has BlurImage(...).
enhance.c has LevelImage(...).

Re: IM really needs this feature

Posted: 2014-06-17T13:57:39-07:00
by VanGog
The blur functions look very hard for me to understand (* but I found interesting explanation at least for gausian filter here http://stackoverflow.com/questions/1696 ... -functions ). The LevelImage seems more simple. I am checking it to understand how it works.

For the case that somebody with the knowledge would read this - my question to the function is what are meanings of these entities: rho, sigma - I see that black_point is rho but why? Does it mean black is expressed in angle? Which colorspace model/diagram should I check?

As far as I understand it so the main job is done by the method LevelPixel image. So IM first calculates scale (every time for every pixel?)

Code: Select all

scale=(white_point != black_point) ? 1.0/(white_point-black_point) : 1.0;
And then you change the color value saved in the pixel variable.

Code: Select all

level_pixel=QuantumRange*gamma_pow(scale*((double) pixel-black_point),1.0/
    gamma);