Sophisticated fuzz with HSL definition?
Re: Sophisticated fuzz with HSL definition?
Notice that I don't understand why you do division here:
u>%minH1%/360
u>%minS1%/255
u>%minL1%/255
If this is conversion from PS to IM, then notice that I did division:
min IM=(1/360)*G$3*100 for hue
which is
min IM=(1/360)*197*100 for hue
Saturation and Lightness/Brightness is untouched
u>%minH1%/360
u>%minS1%/255
u>%minL1%/255
If this is conversion from PS to IM, then notice that I did division:
min IM=(1/360)*G$3*100 for hue
which is
min IM=(1/360)*197*100 for hue
Saturation and Lightness/Brightness is untouched
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
OK so H is in the range of 0 to 360 and S and B are in the range 0 to 100 %. Brightness is not always the same as Lightness. Is there any way to find out whether they are using HSL or HSB (sometimes called HSV)? My old PS CS does not have color values, except for RGB and CMYK.I used Eyedropper tool to manually select color and view it with ColorPicker in Photoshop. There are these values displayed: H [°],S [%],B [%]
B is Brightness which is the same as Lightness
If we assume it is really HSL, then the code in unix syntax is (where I normalize to the range 0 to 1 in the fx expression for simplicity, but you can normalize externally and remove the /360 or /100)
Code: Select all
Hmin=104
Hmax=216
Smin=8
Smax=33
Lmin=31
Lmax=46
convert -size 1x360 gradient: -fx "(u>$Hmin/360 && u<$Hmax/100)?white:black" h_lut.png
convert -size 1x360 gradient: -fx "(u>$Smin/100 && u<$Smax/100)?white:black" s_lut.png
convert -size 1x360 gradient: -fx "(u>$Lmin/100 && u<$Lmax/100)?white:black" l_lut.png
convert h_lut.png s_lut.png l_lut.png -evaluate-sequence multiply lut.png
convert \( test.png -colorspace HSL \) lut.png -clut test_mask_hsl.png
Here is the result after applying the lut to the image:
If it is truly HSB, then the last line would be
Code: Select all
convert \( test.png -colorspace HSB \) lut.png -clut test_mask_hsb.png
Re: Sophisticated fuzz with HSL definition?
I will reply later. if you have version CS2 click on foreground color to display ColorPicker.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
Sorry, I do not have PS CS2 only PS CS.
This also works to make the lut in one command
Note this -fx command is all one line with no line feeds, but is wrapped to another line by the code tags. However, if you put a line feed anywhere in side the double quotes, you do not need end of line characters. So the following is fine also with forced line breaks. Again Unix syntax
This also works to make the lut in one command
Code: Select all
Hmin=104
Hmax=216
Smin=8
Smax=33
Lmin=31
Lmax=46
convert -size 1x360 gradient: -fx "(u.r>$Hmin/360 && u.r<$Hmax/100) && (u.g>$Smin/100 && u.g<$Smax/100) && (u.b>$Lmin/100 && u.b<$Lmax/100)?white:black" lut.png
convert \( test.png -colorspace HSL \) lut.png -clut test_mask_hsl2.png
Code: Select all
Hmin=104
Hmax=216
Smin=8
Smax=33
Lmin=31
Lmax=46
convert -size 1x360 gradient: -fx \
"(u.r>$Hmin/360 && u.r<$Hmax/100) &&
(u.g>$Smin/100 && u.g<$Smax/100) &&
(u.b>$Lmin/100 && u.b<$Lmax/100)?white:black" lut.png
convert \( test.png -colorspace HSL \) lut.png -clut test_mask_hsl2.png
Re: Sophisticated fuzz with HSL definition?
Tested. But why you have your masks B/W and me colored?
Also I the colors selected do not correspond with shadows. In fact, the shadows are not selected at all.
Also I the colors selected do not correspond with shadows. In fact, the shadows are not selected at all.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Sophisticated fuzz with HSL definition?
Sadly, that isn't true for Windows. The quoted string for -fx needs to be on one line.fmw42 wrote: However, if you put a line feed anywhere in side the double quotes, you do not need end of line characters. So the following is fine also with forced line breaks.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
VanGog wrote:Tested. But why you have your masks B/W and me colored?
Also I the colors selected do not correspond with shadows. In fact, the shadows are not selected at all.
What is your code. Did you follow mine latest code exactly. Note the -evaluate sequence in the earlier code that combines each lut to make the logical && so that you get a black/white result rather than color, which is keeping each channel condition separately, thus a color image. How exactly do you want your condition. Is it a logical && to combine channels or a logical || to combine channels. If the latter, then replace -evaluate-sequence multiply with -evaluate sequence add. Or in the last version with only one fx command, use || in stead of && for the between channels conditions.
My result is correct for the HSL values you provided assuming they were interpreted as deg for hue and percent for sat and lightness and you want a logical && to combine the channel conditions. If photoshop is generating other ranges of values (such as 0 to 255 for sat and lightness), then the results would be incorrect. Or perhaps you need to make your min and max ranges wider.
Post a screen snap of the color picker.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
snibgo wrote:Sadly, that isn't true for Windows. The quoted string for -fx needs to be on one line.fmw42 wrote: However, if you put a line feed anywhere in side the double quotes, you do not need end of line characters. So the following is fine also with forced line breaks.
Thanks, snibgo, for the correction.
Re: Sophisticated fuzz with HSL definition?
My ColorPicker:
Notice the key area is selected.
These values are in degrees and percentages, these are original values:
But after convertion:
min IM: 54,72222222 21 29
max IM: 61,66666667 40 33
The last is passed to IM and these values are not in degrees. The original value of hue in degrees was multiplied by 1/360 .
=(1/360)*G4*100
min=(1/360)*197*100=54.72222
max=(1/360)*222*100=61.6
When I add the units description in the 5th column:
Notice the key area is selected.
Yes but converted to Windows syntax.fmw42 wrote: Did you follow mine latest code exactly.
All masks are colored. Not the last only.fmw42 wrote: Note the -evaluate sequence in the earlier code that combines each lut to make the logical && so that you get a black/white result rather than color, which is keeping each channel condition separately, thus a color image.
logical &&fmw42 wrote: How exactly do you want your condition. Is it a logical && to combine channels or a logical || to combine channels. If the latter, then replace -evaluate-sequence multiply with -evaluate sequence add.
Once againfmw42 wrote: My result is correct for the HSL values you provided assuming they were interpreted as deg for hue and percent for sat and lightness and you want a logical && to combine the channel conditions.
These values are in degrees and percentages, these are original values:
Code: Select all
min: 197 21 29
max: 222 40 33
avg: 209,5 30,5 31
Code: Select all
min: 0,547222222 0,21 0,29
max: 0,616666667 0,4 0,33
avg: 0,581944444 0,305 0,31
max IM: 61,66666667 40 33
The last is passed to IM and these values are not in degrees. The original value of hue in degrees was multiplied by 1/360 .
=(1/360)*G4*100
min=(1/360)*197*100=54.72222
max=(1/360)*222*100=61.6
When I add the units description in the 5th column:
Code: Select all
H S Brightness
min: 197 21 29 [°, %, % ]
max: 222 40 33 [°, %, % ]
avg: 209,5 30,5 31 [°, %, % ]
Převod na standardní hodnoty:
min: 0,547222222 0,21 0,29 [1 = 100% ]
max: 0,616666667 0,4 0,33 [1 = 100% ]
avg: 0,581944444 0,305 0,31 [1 = 100% ]
min IM: 54,72222222 21 29 [100 = 100% ]
max IM: 61,66666667 40 33 [100 = 100% ]
avg IM: 58,19444444 30,5 31 [100 = 100% ]
Re: Sophisticated fuzz with HSL definition?
My codes
Edit: this must be mistake:
(u.r>$Hmin/360 && u.r<$Hmax/100
I corrected to 360.
Edit2:
What does not make sense to me is why you devide by 360, when I multiplied by 1/360
Edit3:
Think about my values which I gave you like if I would change them to 100 so they are in 100% all.
Code: Select all
SET Hmin=104
SET Hmax=216
SET Smin=8
SET Smax=33
SET Lmin=31
SET Lmax=46
convert -size 1x360 gradient: -fx "(u>%Hmin%/360 && u<%Hmax%/100)?white:black" h_lut.png
convert -size 1x360 gradient: -fx "(u>%Smin%/100 && u<%Smax%/100)?white:black" s_lut.png
convert -size 1x360 gradient: -fx "(u>%Lmin%/100 && u<%Lmax%/100)?white:black" l_lut.png
convert h_lut.png s_lut.png l_lut.png -evaluate-sequence multiply lut.png
convert ( test.png -colorspace HSL ) lut.png -clut test_mask_hsl.png
pause
Code: Select all
SET Hmin=104
SET Hmax=216
SET Smin=8
SET Smax=33
SET Lmin=31
SET Lmax=46
convert -size 1x360 gradient: -fx "(u.r>%Hmin%/360 && u.r<%Hmax%/100) && (u.g>%Smin%/100 && u.g<%Smax%/100) && (u.b>%Lmin%/100 && u.b<%Lmax%/100)?white:black" lut.png
convert ( test.png -colorspace HSL ) lut.png -clut test_mask_hsl2.png
pause
Code: Select all
SET Hmin=104
SET Hmax=216
SET Smin=8
SET Smax=33
SET Lmin=31
SET Lmax=46
convert -size 1x360 gradient: -fx "(u.r>%Hmin%/360 && u.r<%Hmax%/100) && (u.g>%Smin%/100 && u.g<%Smax%/100) && (u.b>%Lmin%/100 && u.b<%Lmax%/100)?white:black" lut.png
convert ( test.png -colorspace HSL ) lut.png -clut test_mask_hsl3.png
pause
(u.r>$Hmin/360 && u.r<$Hmax/100
I corrected to 360.
Edit2:
What does not make sense to me is why you devide by 360, when I multiplied by 1/360
Edit3:
Think about my values which I gave you like if I would change them to 100 so they are in 100% all.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
1) Yes a typo, that I discovered a little while agoEdit: this must be mistake:
(u.r>$Hmin/360 && u.r<$Hmax/100
I corrected to 360.
Edit2:
What does not make sense to me is why you devide by 360, when I multiplied by 1/360
Edit3:
Think about my values which I gave you like if I would change them to 100 so they are in 100% all.
VanGog
2) divide by 360 is the same as multiply by 1/360
3) That is what I am doing, but converting rather to a fraction 0 to 1 rather than percent 0 to 100%
I am investigating the fact that the mask is not coming out correctly. I think the issue is with
convert \( test.png -colorspace HSL \) lut.png -clut test_mask_hsl.png
I do not believe thta -colorspace is actually changing the image to HSL, but is leaving it as RGB. I am in the process of trying to separate the channels and process them each separately and combine later. I will get back on this as soon as I can figure out what is going on.
But I must ask you if these H,S,L channel conditionals is really what you were doing in PS. If you have some other method of processing in PS, and are not actually using the picked colors for conditional tests, then that could be why you are getting different results. If you are using these picked points in PS, then please explain how you are using them. I certainly do not know what you are really doing in PS to process your image.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
I am starting to think that your point picker colors are HSB and not HSL (single hexcone rather than double hexcone) otherwise the brightness mask is not getting the dark values properly. To validate, I used the values in your colorpicker image
You have rgb=51,67,82 and hsb=209,38,32
# ImageMagick pixel enumeration: 1,1,65535,hsb
0,0: (58.0652%,37.8042%,32.1569%) #94A560C75252 hsb(58.0652%,37.8042%,32.1569%)
These are all in percent. Converting hue from percent to deg I get rounded values of
hsb=209,38,32
Thus, this confirms that you are not using HSL in the colorpicker but HSB!
So I have changed my code as follows:
First I convert all min and max values (in the fx) to the range 0 to 360 and use the i (x) image coordinate as the measure from 0 to 360. Since the hue values are already in the range 0 to 360, nothing needs to be done. The sat and brightness values need to be scaled from the range 0 to 100 to the range 0 to 360 to correspond with the size of the lookup table.
Next I separate the HSB channels to ensure that the are converted from RGB to HSB.
Then I apply the fx luts separately to each appropriate channel.
Then I combine them using -evaluate-sequence multiply to make the mask binary (via logical &&).
Here are the 3 mask images for each channel and the final mask.
hue:
saturation:
brightness:
final binary mask:
Note your saturation range may be shifted too high, since it does not get much of the shadow to the right side of the building on the left side of the image.
The above is all predicated upon the assumption that you are really using HSB not HSL and that values you have presented are in the ranges of hue 0 to 360, sat 0 to 100, and brightness 0 to 100. If any of these are wrong, then that invalidates the above. Please see if you can validate these assumptions. You can also pick points on each of the separated HSB channels and then we would modify the code because the range of HSB is either 0-360,0-255,0-255 or 0-100 for all three if in percent.
I am not that much an expert on PS. How are you validating that the color ranges you used correspond to the regions you want? The color picker in my version does not highlight any pixels in the image with those values. Also if you are using a color picker, why not just pick rgb colors?
Why don't you just use the PS color picker to get an rgb triplet (say it is rgb=51,67,82), then use the Color Range window to set the fuzz value (say it is 40%) to where you can select the regions you want. Then come back to IM and use the same thing.
Just because you create the mask in RGB space, does not restrict you from further processing in HSL colorspace. For example you could use -modulate to change the H,S,L value for pixels only within the mask region.
[/b]
You have rgb=51,67,82 and hsb=209,38,32
Code: Select all
convert -size 1x1 xc:"rgb(51,67,82)" -colorspace HSB txt:-
0,0: (58.0652%,37.8042%,32.1569%) #94A560C75252 hsb(58.0652%,37.8042%,32.1569%)
These are all in percent. Converting hue from percent to deg I get rounded values of
hsb=209,38,32
Thus, this confirms that you are not using HSL in the colorpicker but HSB!
So I have changed my code as follows:
Code: Select all
Hmin=104
Hmax=216
Smin=8
Smax=33
Bmin=31
Bmax=46
convert -size 360x1 xc: -fx "(i>$Hmin && i<$Hmax)?white:black" h_lut2.png
convert -size 360x1 xc: -fx "(i>$Smin*360/100 && i<$Smax*360/100)?white:black" s_lut2.png
convert -size 360x1 xc: -fx "(i>$Bmin*360/100 && i<$Bmax*360/100)?white:black" b_lut2.png
convert test2.png -colorspace hsb -separate test2_hsb_%d.png
convert test2_hsb_0.png h_lut2.png -clut test2_hsb_mask2_0.png
convert test2_hsb_1.png s_lut2.png -clut test2_hsb_mask2_1.png
convert test2_hsb_2.png b_lut2.png -clut test2_hsb_mask2_2.png
convert test2_hsb_mask2_0.png test2_hsb_mask2_1.png test2_hsb_mask2_2.png -evaluate-sequence multiply test2_hsb_mask2.png
Next I separate the HSB channels to ensure that the are converted from RGB to HSB.
Then I apply the fx luts separately to each appropriate channel.
Then I combine them using -evaluate-sequence multiply to make the mask binary (via logical &&).
Here are the 3 mask images for each channel and the final mask.
hue:
saturation:
brightness:
final binary mask:
Note your saturation range may be shifted too high, since it does not get much of the shadow to the right side of the building on the left side of the image.
The above is all predicated upon the assumption that you are really using HSB not HSL and that values you have presented are in the ranges of hue 0 to 360, sat 0 to 100, and brightness 0 to 100. If any of these are wrong, then that invalidates the above. Please see if you can validate these assumptions. You can also pick points on each of the separated HSB channels and then we would modify the code because the range of HSB is either 0-360,0-255,0-255 or 0-100 for all three if in percent.
I am not that much an expert on PS. How are you validating that the color ranges you used correspond to the regions you want? The color picker in my version does not highlight any pixels in the image with those values. Also if you are using a color picker, why not just pick rgb colors?
Why don't you just use the PS color picker to get an rgb triplet (say it is rgb=51,67,82), then use the Color Range window to set the fuzz value (say it is 40%) to where you can select the regions you want. Then come back to IM and use the same thing.
Code: Select all
convert image -fuzz 40% -fill black +opaque "rgb(51,67,82)" -fill white -opaque "rgb(51,67,82)" maskimage
[/b]
Re: Sophisticated fuzz with HSL definition?
RE post #1
First, some basics about the "masks" in Photoshop.
Photoshop has more ways how to achieve same thing which you get with mask in IM:
1) If you really want to create mask, you can e.g. open file, copy some area or colors, close the file and then paste it to another file. So you have new layer. You can select some area or colors in the new layer with image. Then you press icon to create mask. CS2 has icon - press F7 to see Layers and click icon: circle in rectangle. So you created mask. The selected area comes white in the mask, while the rest is black. You see only the area/colors that you selected.
2) Another kind of mask is any kind of selection. You can select with Rect. Margue tools or ctrl+shift+s to select colors. I could use this. I can pick one color of shadow and then I will change icon of Eyedropper to "Add to Sample" to add next colors, so more colors will be selected. Submit. The mask is not visible. Instead of it you see selection.
3) there is yet 3rd mask type which is quick mask (but it is just another name for the invisible mask used in #2), another channel. Pressing Q switches the quick mask mode. When I draw in Quick mask mode, I see red pixels instead black, but in the icon of Channel Quick mask you can see black pixels. Pressing Q finishes Quick mask mode and voiala, you get selection. So in Quick mask mode you can repair your selected areas or colors using drawing tools.
In my image, I used the method #2.
I am absolutely sure I use correct colors. So I selected my colors with color selection tool and then I have copied the pixels to new layer. I only press ctrl+j to copy it to new layer. I make two copies, so I press it once more. One copy will serve to lighten the colors and the second will copy original colors (see 2014-06-02T09:12:00+00:00 point 11).
To be continued...
PS:
If you are able to run WIn32 apps on your system, note that PS CS2 is for free to download and install as a part of packet Adobe Suite. I think this is it:
https://www.adobe.com/cfusion/entitleme ... _downloads
They have there good programs. You need only to register.
Ok, but why are we doing it twice? Once in the calculation in the table, and then in your -fx channel expression?fmw42 wrote: 2) divide by 360 is the same as multiply by 1/360
I showed you the steps above but you probably don't understand what is going on the. Basicly, then I say "select colors" in Photoshop, so it is the same as "create B/W mask" in IM.fmw42 wrote: But I must ask you if these H,S,L channel conditionals is really what you were doing in PS. If you have some other method of processing in PS, and are not actually using the picked colors for conditional tests, then that could be why you are getting different results. If you are using these picked points in PS, then please explain how you are using them. I certainly do not know what you are really doing in PS to process your image.
First, some basics about the "masks" in Photoshop.
Photoshop has more ways how to achieve same thing which you get with mask in IM:
1) If you really want to create mask, you can e.g. open file, copy some area or colors, close the file and then paste it to another file. So you have new layer. You can select some area or colors in the new layer with image. Then you press icon to create mask. CS2 has icon - press F7 to see Layers and click icon: circle in rectangle. So you created mask. The selected area comes white in the mask, while the rest is black. You see only the area/colors that you selected.
2) Another kind of mask is any kind of selection. You can select with Rect. Margue tools or ctrl+shift+s to select colors. I could use this. I can pick one color of shadow and then I will change icon of Eyedropper to "Add to Sample" to add next colors, so more colors will be selected. Submit. The mask is not visible. Instead of it you see selection.
3) there is yet 3rd mask type which is quick mask (but it is just another name for the invisible mask used in #2), another channel. Pressing Q switches the quick mask mode. When I draw in Quick mask mode, I see red pixels instead black, but in the icon of Channel Quick mask you can see black pixels. Pressing Q finishes Quick mask mode and voiala, you get selection. So in Quick mask mode you can repair your selected areas or colors using drawing tools.
In my image, I used the method #2.
I am absolutely sure I use correct colors. So I selected my colors with color selection tool and then I have copied the pixels to new layer. I only press ctrl+j to copy it to new layer. I make two copies, so I press it once more. One copy will serve to lighten the colors and the second will copy original colors (see 2014-06-02T09:12:00+00:00 point 11).
To be continued...
PS:
If you are able to run WIn32 apps on your system, note that PS CS2 is for free to download and install as a part of packet Adobe Suite. I think this is it:
https://www.adobe.com/cfusion/entitleme ... _downloads
They have there good programs. You need only to register.
I open ColorPicker and then I use EyeDrop tool to select the Color in image. It will be displayed in the ColorPicker window. No highlight in the image. Also you must set the fuzz in the ColorPicker, My plan is to collect few colors, not that much as needed in RGB. I use ColorPicker to get the values to table. But the image I have send as demonstration, that is another story. There I had to select the cca 3-10 colors (I dont remember) and probably I used fuzz about 15%. I don't plan to use fuzz in IM, I think it should be possibly to define the colors exactly.fmw42 wrote: I am not that much an expert on PS. How are you validating that the color ranges you used correspond to the regions you want? The color picker in my version does not highlight any pixels in the image with those values. Also if you are using a color picker, why not just pick rgb colors?
Re: Sophisticated fuzz with HSL definition?
Where did you take your colors? Mine are different. Your mask is very close but I want to use the values from Photoshop, but you uses different ones. Did you converted them to HSV? Probably no, otherwise you wouldn't change the code. This brings me to idea why not to create cluvs in HSB and then covert them to HSV?
I mean that things like
takes the performance and maybe are unnecessary, It should be sufficient to convert the colors from HSB to HSV or convert the luvs on the way.
Then the code using HSV method could be used. Very important: this code takes longer then the previous using HSV. The code for HSV was adequately powerful.
I mean that things like
Code: Select all
convert test2.png -colorspace hsb -separate test2_hsb_%%d.png
Then the code using HSV method could be used. Very important: this code takes longer then the previous using HSV. The code for HSV was adequately powerful.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sophisticated fuzz with HSL definition?
The color picker is showing colors in RGB, CMYK, HEX and HSB. HSB is not the same as HSL. I proved that your colors in the color picker are HSB at the top of my last message, by converting the RGB values from your color picker to HSB in IM and got the same values as the color picker shows for HSB.
So I changed my script. This script works differently. I use your raw HSB values in the range 0-360,0-100,0-100 in the script. I do not divide by 360 or any other factor before using -fx. The width of the look up table is 360. I use the x (or i) coordinate to work across the lut one pixel at a time in -fx. So I want the values in your conditionals to be scaled to the range 0 to 360. Since hue is already in that range I can just use the raw hue value. Sat and Bri need to be scaled from the range 0-100 to the range 0-360. Thus I must multiply by 360/100 to do the conversion. The 3 luts (look up tables) now corresponds to test in HSB colorspace. So I must convert your image to HSB and separate channels. Then apply each of the h,s,b luts to the corresponding H,S,B channels. Then I combine the resulting images using -evaluate-sequence multiply to compute the logical && so that all 3 conditionals must pass to make the final mask have white regions. Any other combination returns black.
Once you have the mask, you can now process your original image and do whatever kind of processing your want even if that involves changing HSL values. The mask does not care what colorspace you use to process your image.
If you want to duplicate what you do to create your mask in PS, if I understand correctly, you would use the color picker to get a list of rbg colors and fuzz values for each color. Since the HSB color is the same as the RGB color, you can just use the RGB values for IM. There is no need to complicate it by trying to use HSB colors at this point. I do not know what fuzz value you use, but it could be 0, if you just find only those exact pixels that match that color. For each color and fuzz value use the following to make a mask (where I just use this one color and fuzz value for an example -- replace each with your own values)
repeat that for every color and fuzz value you used in PS
Then combine the masks into one mask. In this case it would like be done by
so that the final mask includes all white pixels in every mask.
I do not use Windows so cannot get PS CS2. But my PS CS shows the same color picker as yours. I thought your were using something else when I said I did not have that.
So I changed my script. This script works differently. I use your raw HSB values in the range 0-360,0-100,0-100 in the script. I do not divide by 360 or any other factor before using -fx. The width of the look up table is 360. I use the x (or i) coordinate to work across the lut one pixel at a time in -fx. So I want the values in your conditionals to be scaled to the range 0 to 360. Since hue is already in that range I can just use the raw hue value. Sat and Bri need to be scaled from the range 0-100 to the range 0-360. Thus I must multiply by 360/100 to do the conversion. The 3 luts (look up tables) now corresponds to test in HSB colorspace. So I must convert your image to HSB and separate channels. Then apply each of the h,s,b luts to the corresponding H,S,B channels. Then I combine the resulting images using -evaluate-sequence multiply to compute the logical && so that all 3 conditionals must pass to make the final mask have white regions. Any other combination returns black.
Once you have the mask, you can now process your original image and do whatever kind of processing your want even if that involves changing HSL values. The mask does not care what colorspace you use to process your image.
If you want to duplicate what you do to create your mask in PS, if I understand correctly, you would use the color picker to get a list of rbg colors and fuzz values for each color. Since the HSB color is the same as the RGB color, you can just use the RGB values for IM. There is no need to complicate it by trying to use HSB colors at this point. I do not know what fuzz value you use, but it could be 0, if you just find only those exact pixels that match that color. For each color and fuzz value use the following to make a mask (where I just use this one color and fuzz value for an example -- replace each with your own values)
Code: Select all
convert image -fuzz 40% -fill black +opaque "rgb(51,67,82)" -fill white -opaque "rgb(51,67,82)" maskimage
Then combine the masks into one mask. In this case it would like be done by
Code: Select all
convert mask1 mask2 mask3 ... -evaluate-sequence add finalmask
I do not use Windows so cannot get PS CS2. But my PS CS shows the same color picker as yours. I thought your were using something else when I said I did not have that.