Method: Magick::Image#segment
- Defined in:
- ext/RMagick/rmimage.c
permalink #segment(*args) ⇒ Object
Call SegmentImage.
Ruby usage:
- @verbatim Image#segment @endverbatim
- @verbatim Image#segment(colorspace) @endverbatim
- @verbatim Image#segment(colorspace,cluster_threshold) @endverbatim
- @verbatim Image#segment(colorspace,cluster_threshold,smoothing_threshold) @endverbatim
- @verbatim Image#segment(colorspace,cluster_threshold,smoothing_threshold,verbose) @endverbatim
Notes:
- Default colorspace is RGBColorspace
- Default cluster_threshold is 1.0
- Default smoothing_threshold is 1.5
- Default verbose is false
- The default values are the same as Magick++
11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 |
# File 'ext/RMagick/rmimage.c', line 11624
VALUE
Image_segment(int argc, VALUE *argv, VALUE self)
{
Image *image, *new_image;
int colorspace = RGBColorspace; // These are the Magick++ defaults
unsigned int verbose = MagickFalse;
double cluster_threshold = 1.0;
double smoothing_threshold = 1.5;
image = rm_check_destroyed(self);
switch (argc)
{
case 4:
verbose = RTEST(argv[3]);
case 3:
smoothing_threshold = NUM2DBL(argv[2]);
case 2:
cluster_threshold = NUM2DBL(argv[1]);
case 1:
VALUE_TO_ENUM(argv[0], colorspace, ColorspaceType);
case 0:
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 4)", argc);
break;
}
new_image = rm_clone_image(image);
(void) SegmentImage(new_image, colorspace, verbose, cluster_threshold, smoothing_threshold);
rm_check_image_exception(new_image, DestroyOnError);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|