Method: Magick::Image#random_threshold_channel

Defined in:
ext/RMagick/rmimage.c

#random_threshold_channel(*args) ⇒ Object

Call RandomThresholdImageChannel.

Ruby usage:

- @verbatim Image#random_threshold_channel(geometry_str) @endverbatim
- @verbatim Image#random_threshold_channel(geometry_str, channel) @endverbatim
- @verbatim Image#random_threshold_channel(geometry_str, channel, ...) @endverbatim

Notes:

- Default channel is AllChannels

Parameters:

  • argc

    number of input arguments

  • argv

    array of input arguments

  • self

    this object

Returns:

  • a new image

[View source]

10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
# File 'ext/RMagick/rmimage.c', line 10469

VALUE
Image_random_threshold_channel(int argc, VALUE *argv, VALUE self)
{
    Image *image, *new_image;
    ChannelType channels;
    char *thresholds;
    volatile VALUE geom_str;
    ExceptionInfo exception;

    image = rm_check_destroyed(self);

    channels = extract_channels(&argc, argv);

    // There must be 1 remaining argument.
    if (argc == 0)
    {
        rb_raise(rb_eArgError, "missing threshold argument");
    }
    else if (argc > 1)
    {
        raise_ChannelType_error(argv[argc-1]);
    }

    // Accept any argument that has a to_s method.
    geom_str = rm_to_s(argv[0]);
    thresholds = StringValuePtr(geom_str);

    new_image = rm_clone_image(image);

    GetExceptionInfo(&exception);

    (void) RandomThresholdImageChannel(new_image, channels, thresholds, &exception);
    rm_check_exception(&exception, new_image, DestroyOnError);

    (void) DestroyExceptionInfo(&exception);

    return rm_image_new(new_image);
}