On this page:
9.8.1 Extracting a color

9.8 ColorSelect

Filters out all colors except the color specified via the r0, g0 and b0 parameters. The pixels filtered out are all mapped to transparent black.

 

Parameters

 

Default

 

Range    

 

Description

 

ProgramString

 

""

 

n/a

 

This must be set to Color_Select.

 

 

 

 

 

NumParams

 

0

 

(0 - 4)

 

This must be set to 3

 

 

 

 

 

r0

 

0.0

 

n/a

 

The red component of the color to retain in the output.

 

 

 

 

 

g0

 

0.0

 

n/a

 

The green component of the color to retain in the output.

 

 

 

 

 

b0

 

0.0

 

n/a

 

The blue component of the color to retain in the output.

 

 

 

 

 

a0

 

0.0

 

n/a

 

The alpha component of the color to retain in the output.

 

 

 

 

 

r1

 

0.0

 

n/a

 

r1, g1, b1 and a1 give the tolerance range within a color is shown. For example, suppose the color component to be retained is 0.6 and the tolerance for that component is 0.1, then the colors whose component falls in the range [0.5,0.7] will show through.

 

 

 

 

 

g1

 

0.0

 

n/a

 

The green component tolerance.

 

 

 

 

 

b1

 

0.0

 

n/a

 

The blue component tolerance.

 

 

 

 

 

a1

 

0.0

 

n/a

 

The alpha component tolerance.

 

 

 

 

 

r2

 

0.0

 

n/a

 

r2, g2, b2 and a2 give the component-wise factors by which neighbouring pixels are blended together (anti-aliased) in order to smooth out jagged edges that occur in such selection operations.

 

 

 

 

 

g2

 

0.0

 

n/a

 

The green anti-aliasing factor.

 

 

 

 

 

b2

 

0.0

 

n/a

 

The blue anti-aliasing factor.

 

 

 

 

 

a2

 

0.0

 

n/a

 

The alpha anti-aliasing factor.

 

 

 

 

 

GlobalMode

 

0

 

[0,1]

 

See GlobalMode.

Input pattern: (A)
Image-Op: Depends on the GlobalMode parameter.

9.8.1 Extracting a color
; muSE v2
; 
;  My unbelievably awesome style.
;  This style greyscales the user image
;  but maintains the stuff that are coloured blue. :)
 
(style-parameters)
 
(segment-durations 8.0)
 
(define muvee-global-effect
  (effect-stack (effect "Perspective" (A))
                (effect "CropMedia" (A))))
 
(define muvee-segment-effect
  (layers (A)
          (effect "Greyscale" ()
                  (input 0 A))
 
          (effect "FragmentProgram" ()
                  (input 0 A)
                  (param "ProgramString" Color_Select)
                  (param "a0"   1.0)    ; ColorInterest
                  (param "r0"   0.0)    ; ColorInterest
                  (param "g0"   0.0)    ; ColorInterest
                  (param "b0"   1.0)    ; ColorInterest
 
                  (param "a1"   0.5)    ; ColorTolerance
                  (param "r1"   0.5)    ; ColorTolerance
                  (param "g1"   0.5)    ; ColorTolerance
                  (param "b1"   0.5)    ; ColorTolerance
 
                  (param "a2"   0.6)    ; LRP Tolerance
                  (param "r2"   0.6)    ; LRP Tolerance
                  (param "g2"   0.6)    ; LRP Tolerance
                  (param "b2"   0.6)    ; LRP Tolerance
 
                  (param "NumParams" 3))))

The Color_Select program string is a color selector shader. From muse, we send in the color we want to retain (referred to as our colorInterest) and the Color_Select returns sections of the picture with that color. Refer to the screenshot below. Only the blue colored pixels are retained and the rest are in grey.

If you look at the segment-level-effect, our layers has two effect. The first one is a Greyscale effect and the next one is our FragmentProgram that will only return stuff that are colored blue. The {a0 ,r0 ,g0 ,b0} set of paramters initialize the color we want to retain. As you can see, it is set to blue. The {a1 ,r1 ,g1 ,b1} sets the threshold at which we’ll accept colors. Finally {a2 ,r2 ,g2 ,b2} sets the amount of interpolation we want *after* the threshold. The best way to understand these parameters is to set them to zero, which effectively disables them, so you can compare the output with and the without the smoothing.