Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Olena
pylene
Commits
62fee73c
Commit
62fee73c
authored
Jan 28, 2019
by
Edwin Carlinet
Browse files
Fix filter view test.
parent
b7eef55a
Pipeline
#12755
failed with stages
in 8 minutes and 49 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pylene/include/mln/core/image/view/filter.hpp
View file @
62fee73c
...
...
@@ -24,10 +24,10 @@ namespace mln
public:
/// Type definitions
/// \{
using
reference
=
std
::
invoke_result_t
<
F
&
,
image_reference_t
<
I
>>
;
using
value_type
=
std
::
decay_t
<
reference
>
;
using
typename
filter_view
::
image_adaptor
::
new_pixel_type
;
using
typename
filter_view
::
image_adaptor
::
point_type
;
using
typename
filter_view
::
image_adaptor
::
reference
;
using
typename
filter_view
::
image_adaptor
::
value_type
;
using
domain_type
=
detail
::
filtered
<
I
,
F
>
;
/// \}
...
...
tests/core/image/view/filter.cpp
View file @
62fee73c
...
...
@@ -2,6 +2,7 @@
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/image/view/filter.hpp>
#include <mln/core/algorithm/all_of.hpp>
#include <mln/core/algorithm/fill.hpp>
#include <mln/core/algorithm/iota.hpp>
...
...
@@ -15,16 +16,15 @@
TEST
(
View
,
filter_readonly
)
{
using
namespace
mln
;
using
namespace
mln
::
experimental
::
ops
;
box2d
dom
{{
-
1
,
-
2
},
{
3
,
3
}};
image2d
<
int
>
ima
(
dom
);
mln
::
box2d
dom
=
{{
-
1
,
-
2
},
{
3
,
3
}};
mln
::
image2d
<
int
>
ima
(
dom
);
iota
(
ima
,
0
);
auto
x
=
view
::
filter
(
ima
,
[](
int
v
)
{
return
v
>
10
;
});
mln
::
experimental
::
iota
(
ima
,
0
);
auto
x
=
mln
::
view
::
filter
(
ima
,
[](
int
v
)
{
return
v
>
10
;
});
ASSERT_TRUE
(
mln
::
experimental
::
all
(
x
>
10
));
ASSERT_TRUE
(
mln
::
experimental
::
all
_of
(
x
>
10
));
mln_foreach_new
(
auto
&&
pix
,
ima
.
new_pixels
())
{
...
...
@@ -41,31 +41,29 @@ TEST(View, filter_readonly)
TEST
(
View
,
filter_writable
)
{
using
namespace
mln
;
using
namespace
mln
::
experimental
::
ops
;
box2d
dom
{{
-
1
,
-
2
},
{
3
,
3
}};
image2d
<
int
>
ima
(
dom
);
mln
::
box2d
dom
{{
-
1
,
-
2
},
{
3
,
3
}};
mln
::
image2d
<
int
>
ima
(
dom
);
iota
(
ima
,
0
);
auto
x
=
view
::
filter
(
ima
,
[](
int
v
)
{
return
v
>
10
;
});
mln
::
experimental
::
iota
(
ima
,
0
);
auto
x
=
mln
::
view
::
filter
(
ima
,
[](
int
v
)
{
return
v
>
10
;
});
fill
(
x
,
10
);
ASSERT_TRUE
(
mln
::
experimental
::
all
(
ima
<=
10
));
mln
::
experimental
::
fill
(
x
,
10
);
ASSERT_TRUE
(
mln
::
experimental
::
all
_of
(
ima
<=
10
));
}
TEST
(
View
,
filter_twice
)
{
using
namespace
mln
;
using
namespace
mln
::
experimental
::
ops
;
box2d
dom
{{
-
1
,
-
2
},
{
3
,
3
}};
image2d
<
int
>
ima
(
dom
);
mln
::
box2d
dom
=
{{
-
1
,
-
2
},
{
3
,
3
}};
mln
::
image2d
<
int
>
ima
(
dom
);
iota
(
ima
,
0
);
auto
u
=
view
::
filter
(
ima
,
[](
int
v
)
{
return
v
>
10
&&
v
<
15
;
});
mln
::
experimental
::
iota
(
ima
,
0
);
auto
u
=
mln
::
view
::
filter
(
ima
,
[](
int
v
)
{
return
v
>
10
&&
v
<
15
;
});
// FIXME:
// auto x = view::filter(ima, [](int v) { return v > 10; });
...
...
@@ -91,10 +89,10 @@ TEST(View, filter_twice)
ASSERT_EQ
(
pix
.
val
(),
ima
(
pix
.
point
()));
}
image2d
<
int
>
before
=
clone
(
ima
);
fill
(
u
,
1
);
mln
::
image2d
<
int
>
before
=
mln
::
experimental
::
clone
(
ima
);
mln
::
experimental
::
fill
(
u
,
1
);
{
mln_foreach_new
((
auto
[
old_v
,
new_v
]),
mln
::
ranges
::
view
::
zip
(
before
.
new_values
(),
u
.
new_values
()))
mln_foreach_new
((
auto
[
old_v
,
new_v
]),
mln
::
ranges
::
view
::
zip
(
before
.
new_values
(),
ima
.
new_values
()))
{
if
(
old_v
>
10
&&
old_v
<
15
)
ASSERT_EQ
(
1
,
new_v
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment