Method: Vips::Image#ifthenelse

Defined in:
lib/vips/image.rb

#ifthenelse(th, el, opts = {}) ⇒ Image

Select pixels from th if self is non-zero and from el if self is zero. Use the :blend option to fade smoothly between th and el.

Parameters:

  • th (Image, Real, Array<Real>)

    true values

  • el (Image, Real, Array<Real>)

    false values

  • opts (Hash) (defaults to: {})

    set of options

Options Hash (opts):

  • :blend (Boolean) — default: false

    Blend smoothly between th and el

Returns:

  • (Image)

    merged image



1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
# File 'lib/vips/image.rb', line 1239

def ifthenelse(th, el, opts = {}) 
    match_image = [th, el, self].find {|x| x.is_a? Vips::Image}

    if not th.is_a? Vips::Image
        th = Argument::imageize match_image, th
    end
    if not el.is_a? Vips::Image
        el = Argument::imageize match_image, el
    end

    Vips::call_base "ifthenelse", self, "", [th, el, opts]
end