/* * call-seq: * sub(val[,mask]) * * Return new CvScalar if <i>val</i> is CvScalar or compatible object. * self[I] - val[I] * Or return new CvMat if <i>val</i> is CvMat or subclass. */ VALUE rb_sub(int argc, VALUE *argv, VALUE self) { VALUE val, mask; rb_scan_args(argc, argv, "11", &val, &mask); if (rb_obj_is_kind_of(val, cCvMat::rb_class())) { CvArr *val_ptr = CVARR(val); VALUE dest = Qnil; try { dest = cCvMat::new_object(cvGetSize(val_ptr), cvGetElemType(val_ptr)); cvSubRS(val_ptr, *CVSCALAR(self), CVARR(dest), MASK(mask)); } catch (cv::Exception& e) { raise_cverror(e); } return dest; } else { CvScalar *src = CVSCALAR(self); CvScalar scl = VALUE_TO_CVSCALAR(val); return new_object(cvScalar(src->val[0] - scl.val[0], src->val[1] - scl.val[1], src->val[2] - scl.val[2], src->val[3] - scl.val[3])); } }
/* * call-seq: * sub(val[,mask]) * * Return new CvScalar if <i>val</i> is CvScalar or compatible object. * self[I] - val[I] * Or return new CvMat if <i>val</i> is CvMat or subclass. */ VALUE rb_sub(int argc, VALUE *argv, VALUE self) { VALUE val, mask; rb_scan_args(argc, argv, "11", &val, &mask); if(rb_obj_is_kind_of(val, cCvMat::rb_class())){ VALUE dest = cCvMat::new_object(cvGetSize(CVARR(val)), cvGetElemType(CVARR(val))); cvSubRS(CVARR(val), *CVSCALAR(self), CVARR(dest), MASK(mask)); return dest; }else{ CvScalar *src = CVSCALAR(self), scl = VALUE_TO_CVSCALAR(val); return new_object(cvScalar(src->val[0] - scl.val[0], src->val[1] - scl.val[1], src->val[2] - scl.val[2], src->val[3] - scl.val[3])); } }