1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00
This commit is contained in:
ser1zw 2013-06-15 16:31:24 +09:00
parent 52410fc0f4
commit 392d32b9d3
2 changed files with 16 additions and 26 deletions

View file

@ -4755,7 +4755,7 @@ rb_flood_fill_bang(int argc, VALUE *argv, VALUE self)
try {
CvSize size = cvGetSize(self_ptr);
// TODO: Change argument format to set mask
mask = new_object(size.width + 2, size.height + 2, CV_MAKETYPE(CV_8U, 1));
mask = new_object(size.height + 2, size.width + 2, CV_MAKETYPE(CV_8U, 1));
CvMat* mask_ptr = CVMAT(mask);
cvSetZero(mask_ptr);
cvFloodFill(self_ptr,

View file

@ -1169,10 +1169,10 @@ class TestCvMat_imageprocessing < OpenCVTestCase
end
def test_flood_fill
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i, c|
if (i >= 32 and i < 96) and (j >= 32 and j < 96)
mat0 = create_cvmat(128, 256, :cv8u, 1) { |j, i, c|
if (i >= 32 and i < 224) and (j >= 32 and j < 96)
CvScalar.new(255)
elsif (i >= 16 and i < 112) and (j >= 16 and j < 112)
elsif (i >= 16 and i < 240) and (j >= 16 and j < 112)
CvScalar.new(192)
else
CvScalar.new(128)
@ -1189,50 +1189,40 @@ class TestCvMat_imageprocessing < OpenCVTestCase
mat5, comp5, mask5 = mat05.flood_fill!(point, 0, CvScalar.new(0), CvScalar.new(64),
{:connectivity => 8, :fixed_range => true, :mask_only => true})
assert_equal('8c6a235fdf4c9c4f6822a45daac5b1af', hash_img(mat1))
assert_equal(5120.0, comp1.area)
assert_equal(9216.0, comp1.area)
assert_equal(16, comp1.rect.x)
assert_equal(16, comp1.rect.y)
assert_equal(96, comp1.rect.width)
assert_equal(224, comp1.rect.width)
assert_equal(96, comp1.rect.height)
assert_cvscalar_equal(CvScalar.new(0, 0, 0, 0), comp1.value)
assert_equal('1fd2537966283987b39c8b2c9d778383', hash_img(mask1))
assert_equal('7456e5de74bb8b4e783d04bbf1904644', hash_img(mat2))
assert_equal(12288.0, comp2.area)
assert_equal(20480.0, comp2.area)
assert_equal(0, comp2.rect.x)
assert_equal(0, comp2.rect.y)
assert_equal(128, comp2.rect.width)
assert_equal(256, comp2.rect.width)
assert_equal(128, comp2.rect.height)
assert_cvscalar_equal(CvScalar.new(0, 0, 0, 0), comp2.value)
assert_equal('847934f5170e2072cdfd63e16a1e06ad', hash_img(mask2))
assert_equal('df720005423762ca1b68e06571f58b21', hash_img(mat3))
assert_equal(9216.0, comp3.area)
assert_equal(21504.0, comp3.area)
assert_equal(16, comp3.rect.x)
assert_equal(16, comp3.rect.y)
assert_equal(96, comp3.rect.width)
assert_equal(224, comp3.rect.width)
assert_equal(96, comp3.rect.height)
assert_cvscalar_equal(CvScalar.new(0, 0, 0, 0), comp3.value)
assert_equal('7833f4c85c77056db71e33ae8072a1b5', hash_img(mat4))
assert_equal(9216.0, comp4.area)
assert_equal(21504.0, comp4.area)
assert_equal(16, comp4.rect.x)
assert_equal(16, comp4.rect.y)
assert_equal(96, comp4.rect.width)
assert_equal(224, comp4.rect.width)
assert_equal(96, comp4.rect.height)
assert_cvscalar_equal(CvScalar.new(220, 0, 0, 0), comp4.value)
assert_equal('b34b0269872fe3acde0e0c73e5cdd23b', hash_img(mask4))
assert_cvscalar_equal(CvScalar.new(228, 0, 0, 0), comp4.value)
assert_equal('7833f4c85c77056db71e33ae8072a1b5', hash_img(mat5))
assert_equal('7833f4c85c77056db71e33ae8072a1b5', hash_img(mat05))
assert_equal(9216.0, comp5.area)
assert_equal(21504.0, comp5.area)
assert_equal(16, comp5.rect.x)
assert_equal(16, comp5.rect.y)
assert_equal(96, comp5.rect.width)
assert_equal(224, comp5.rect.width)
assert_equal(96, comp5.rect.height)
assert_cvscalar_equal(CvScalar.new(220, 0, 0, 0), comp5.value)
assert_equal('b34b0269872fe3acde0e0c73e5cdd23b', hash_img(mask5))
assert_cvscalar_equal(CvScalar.new(228, 0, 0, 0), comp5.value)
assert_raise(TypeError) {
mat0.flood_fill(DUMMY_OBJ, 0)