mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
tested CvMat#watershed
This commit is contained in:
parent
493644a55a
commit
9bcc37aa92
3 changed files with 26 additions and 5 deletions
|
@ -363,7 +363,7 @@ void define_ruby_class()
|
|||
rb_define_method(rb_klass, "find_contours!", RUBY_METHOD_FUNC(rb_find_contours_bang), -1);
|
||||
rb_define_method(rb_klass, "pyr_segmentation", RUBY_METHOD_FUNC(rb_pyr_segmentation), -1);
|
||||
rb_define_method(rb_klass, "pyr_mean_shift_filtering", RUBY_METHOD_FUNC(rb_pyr_mean_shift_filtering), -1);
|
||||
rb_define_method(rb_klass, "watershed", RUBY_METHOD_FUNC(rb_watershed), 0);
|
||||
rb_define_method(rb_klass, "watershed", RUBY_METHOD_FUNC(rb_watershed), 1);
|
||||
|
||||
rb_define_method(rb_klass, "moments", RUBY_METHOD_FUNC(rb_moments), -1);
|
||||
|
||||
|
@ -4337,10 +4337,8 @@ rb_pyr_mean_shift_filtering(int argc, VALUE *argv, VALUE self)
|
|||
* Does watershed segmentation.
|
||||
*/
|
||||
VALUE
|
||||
rb_watershed(VALUE self)
|
||||
rb_watershed(VALUE self, VALUE markers)
|
||||
{
|
||||
VALUE markers = cCvMat::new_object(cvGetSize(CVARR(self)), CV_32SC1);
|
||||
cvZero(CVARR(markers));
|
||||
cvWatershed(CVARR(self), CVARR(markers));
|
||||
return markers;
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ VALUE rb_find_contours(int argc, VALUE *argv, VALUE self);
|
|||
VALUE rb_find_contours_bang(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_pyr_segmentation(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_pyr_mean_shift_filtering(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_watershed(VALUE self);
|
||||
VALUE rb_watershed(VALUE self, VALUE markers);
|
||||
|
||||
VALUE rb_moments(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
|
|
|
@ -1251,5 +1251,28 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
assert_equal('963b26f51b14f175fbbf128e9b9e979f', hash_img(img2))
|
||||
assert_equal(11, seq2.total)
|
||||
end
|
||||
|
||||
|
||||
def test_pyr_mean_shift_filtering
|
||||
mat0 = CvMat.load(FILENAME_LENA256x256, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
mat1 = mat0.pyr_mean_shift_filtering(30, 30)
|
||||
mat2 = mat0.pyr_mean_shift_filtering(30, 30, 2)
|
||||
mat3 = mat0.pyr_mean_shift_filtering(30, 30, nil, CvTermCriteria.new(3, 0.01))
|
||||
|
||||
assert_equal('6887e96bc5dfd552f76ac5411b394775', hash_img(mat1))
|
||||
assert_equal('3cd9c4983fcabeafa04be200d5e08841', hash_img(mat2))
|
||||
assert_equal('e37f0157f93fe2a98312ae6b768e8295', hash_img(mat3))
|
||||
end
|
||||
|
||||
def test_watershed
|
||||
mat0 = CvMat.load(FILENAME_LENA256x256, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
marker = CvMat.new(mat0.cols, mat0.rows, :cv32s, 1).set_zero
|
||||
marker[150, 150] = CvScalar.new(1, 1, 1, 1)
|
||||
marker[210, 210] = CvScalar.new(2, 2, 2, 2)
|
||||
marker[40, 90] = CvScalar.new(3, 3, 3, 3)
|
||||
|
||||
mat1 = mat0.watershed(marker)
|
||||
assert_equal('ee6bec03296039c8df1899d3edc4684e', hash_img(mat1))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue