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
177e8037
Commit
177e8037
authored
Jun 16, 2020
by
Edwin Carlinet
Browse files
Old API cleaning.
Rename mln_foreach_new -> mln_foreach.
parent
7d850b1e
Changes
33
Hide whitespace changes
Inline
Side-by-side
bench/BMMorphers.cpp
View file @
177e8037
...
...
@@ -53,7 +53,7 @@ unsigned threshold1_bis(mln::image2d<uint8_t> f, uint8_t v)
unsigned
threshold2
(
mln
::
image2d
<
uint8_t
>
f
,
uint8_t
v
)
{
unsigned
count
=
0
;
mln_foreach
_new
(
auto
val
,
f
.
values
())
mln_foreach
(
auto
val
,
f
.
values
())
count
+=
(
val
<
v
);
return
count
;
...
...
@@ -62,7 +62,7 @@ unsigned threshold2(mln::image2d<uint8_t> f, uint8_t v)
unsigned
threshold3
(
mln
::
image2d
<
uint8_t
>
f
,
uint8_t
v
)
{
unsigned
count
=
0
;
mln_foreach
_new
(
auto
px
,
f
.
pixels
())
mln_foreach
(
auto
px
,
f
.
pixels
())
count
+=
(
px
.
val
()
<
v
);
return
count
;
}
...
...
bench/BMReference_Linear.cpp
View file @
177e8037
...
...
@@ -9,7 +9,7 @@
void
Mult_Inplace_New_Values
(
mln
::
image2d
<
uint8_t
>&
img
)
{
mln_foreach
_new
(
auto
&
v
,
img
.
values
())
mln_foreach
(
auto
&
v
,
img
.
values
())
{
v
*=
2
;
}
...
...
@@ -17,7 +17,7 @@ void Mult_Inplace_New_Values(mln::image2d<uint8_t>& img)
void
Mult_Inplace_New_Pixels
(
mln
::
image2d
<
uint8_t
>&
img
)
{
mln_foreach
_new
(
auto
&&
px
,
img
.
pixels
())
mln_foreach
(
auto
&&
px
,
img
.
pixels
())
{
px
.
val
()
*=
2
;
}
...
...
@@ -76,7 +76,7 @@ void Threshold_Inplace_New_Values(mln::image2d<uint8_t>& img)
{
constexpr
uint8_t
t
=
128
;
mln_foreach
_new
(
auto
&
v
,
img
.
values
())
mln_foreach
(
auto
&
v
,
img
.
values
())
{
v
=
v
<
t
?
0
:
255
;
}
...
...
@@ -86,7 +86,7 @@ void Threshold_Inplace_New_Pixels(mln::image2d<uint8_t>& img)
{
constexpr
uint8_t
t
=
128
;
mln_foreach
_new
(
auto
&&
px
,
img
.
pixels
())
mln_foreach
(
auto
&&
px
,
img
.
pixels
())
{
px
.
val
()
=
px
.
val
()
<
t
?
0
:
255
;
}
...
...
@@ -150,7 +150,7 @@ void Threshold_New_Pixels(const mln::image2d<uint8_t>& in, mln::image2d<uint8_t>
void
LUT_Inplace_New_Values
(
const
uint8_t
LUT
[],
mln
::
image2d
<
uint8_t
>&
img
)
{
mln_foreach
_new
(
auto
&
v
,
img
.
values
())
mln_foreach
(
auto
&
v
,
img
.
values
())
{
v
=
LUT
[
v
];
}
...
...
@@ -158,7 +158,7 @@ void LUT_Inplace_New_Values(const uint8_t LUT[], mln::image2d<uint8_t>& img)
void
LUT_Inplace_New_Pixels
(
const
uint8_t
LUT
[],
mln
::
image2d
<
uint8_t
>&
img
)
{
mln_foreach
_new
(
auto
&&
px
,
img
.
pixels
())
mln_foreach
(
auto
&&
px
,
img
.
pixels
())
{
px
.
val
()
=
LUT
[
px
.
val
()];
}
...
...
bench/BMReference_Linear_Reversed.cpp
View file @
177e8037
...
...
@@ -11,7 +11,7 @@
void
Mult_Inplace_New_Values_Reversed
(
mln
::
image2d
<
uint8_t
>&
img
)
{
auto
reversed_values
=
mln
::
ranges
::
view
::
reverse
(
img
.
values
());
mln_foreach
_new
(
auto
&
v
,
reversed_values
)
mln_foreach
(
auto
&
v
,
reversed_values
)
{
v
*=
2
;
}
...
...
@@ -20,7 +20,7 @@ void Mult_Inplace_New_Values_Reversed(mln::image2d<uint8_t>& img)
void
Mult_Inplace_New_Pixels_Reversed
(
mln
::
image2d
<
uint8_t
>&
img
)
{
auto
reversed_pixels
=
mln
::
ranges
::
view
::
reverse
(
img
.
pixels
());
mln_foreach
_new
(
auto
&&
px
,
reversed_pixels
)
mln_foreach
(
auto
&&
px
,
reversed_pixels
)
{
px
.
val
()
*=
2
;
}
...
...
@@ -84,7 +84,7 @@ void Threshold_Inplace_New_Values_Reversed(mln::image2d<uint8_t>& img)
constexpr
uint8_t
t
=
128
;
auto
reversed_values
=
mln
::
ranges
::
view
::
reverse
(
img
.
values
());
mln_foreach
_new
(
auto
&
v
,
reversed_values
)
mln_foreach
(
auto
&
v
,
reversed_values
)
{
v
=
v
<
t
?
0
:
255
;
}
...
...
@@ -95,7 +95,7 @@ void Threshold_Inplace_New_Pixels_Reversed(mln::image2d<uint8_t>& img)
constexpr
uint8_t
t
=
128
;
auto
reversed_pixels
=
mln
::
ranges
::
view
::
reverse
(
img
.
pixels
());
mln_foreach
_new
(
auto
&&
px
,
reversed_pixels
)
mln_foreach
(
auto
&&
px
,
reversed_pixels
)
{
px
.
val
()
=
px
.
val
()
<
t
?
0
:
255
;
}
...
...
@@ -164,7 +164,7 @@ void Threshold_New_Pixels_Reversed(const mln::image2d<uint8_t>& input, mln::imag
void
LUT_Inplace_New_Values_Reversed
(
const
uint8_t
LUT
[],
mln
::
image2d
<
uint8_t
>&
img
)
{
mln_foreach
_new
(
auto
&
v
,
img
.
values
())
mln_foreach
(
auto
&
v
,
img
.
values
())
{
v
=
LUT
[
v
];
}
...
...
@@ -172,7 +172,7 @@ void LUT_Inplace_New_Values_Reversed(const uint8_t LUT[], mln::image2d<uint8_t>&
void
LUT_Inplace_New_Pixels_Reversed
(
const
uint8_t
LUT
[],
mln
::
image2d
<
uint8_t
>&
img
)
{
mln_foreach
_new
(
auto
&&
px
,
img
.
pixels
())
mln_foreach
(
auto
&&
px
,
img
.
pixels
())
{
px
.
val
()
=
LUT
[
px
.
val
()];
}
...
...
doc/source/snippets/first_start_1.cpp
View file @
177e8037
...
...
@@ -12,28 +12,28 @@ int main()
std
::
cout
<<
"== Traversing forward ==
\n
"
;
std
::
cout
<<
"Traversing through points.
\n
"
;
mln_foreach
_new
(
auto
p
,
f
.
domain
())
mln_foreach
(
auto
p
,
f
.
domain
())
fmt
::
print
(
"f({},{}) = {}
\n
"
,
p
.
x
(),
p
.
y
(),
f
(
p
));
std
::
cout
<<
"Traversing on values.
\n
"
;
mln_foreach
_new
(
int
x
,
f
.
values
())
mln_foreach
(
int
x
,
f
.
values
())
std
::
cout
<<
x
<<
"
\n
"
;
std
::
cout
<<
"Traversing with pixels.
\n
"
;
mln_foreach
_new
(
auto
px
,
f
.
pixels
())
mln_foreach
(
auto
px
,
f
.
pixels
())
fmt
::
print
(
"f({},{}) = {}
\n
"
,
px
.
point
().
x
(),
px
.
point
().
y
(),
px
.
val
());
std
::
cout
<<
"
\n
== Traversing backward ==
\n
"
;
std
::
cout
<<
"Traversing through points.
\n
"
;
mln_foreach
_new
(
auto
p
,
mln
::
ranges
::
view
::
reverse
(
f
.
domain
()))
mln_foreach
(
auto
p
,
mln
::
ranges
::
view
::
reverse
(
f
.
domain
()))
fmt
::
print
(
"f({},{}) = {}
\n
"
,
p
.
x
(),
p
.
y
(),
f
(
p
));
std
::
cout
<<
"Traversing on values.
\n
"
;
mln_foreach
_new
(
auto
x
,
mln
::
ranges
::
view
::
reverse
(
f
.
values
()))
mln_foreach
(
auto
x
,
mln
::
ranges
::
view
::
reverse
(
f
.
values
()))
std
::
cout
<<
x
<<
"
\n
"
;
std
::
cout
<<
"Traversing with pixels.
\n
"
;
mln_foreach
_new
(
auto
px
,
mln
::
ranges
::
view
::
reverse
(
f
.
pixels
()))
mln_foreach
(
auto
px
,
mln
::
ranges
::
view
::
reverse
(
f
.
pixels
()))
fmt
::
print
(
"f({},{}) = {}
\n
"
,
px
.
point
().
x
(),
px
.
point
().
y
(),
px
.
val
());
}
pylene/include/mln/contrib/meanshift/meanshift.hpp
View file @
177e8037
...
...
@@ -31,7 +31,7 @@ namespace mln
mln
::
se
::
rect2d
win
(
2
*
SR
+
1
,
2
*
SR
+
1
);
auto
g
=
[](
double
x
)
->
double
{
return
std
::
exp
(
-
x
);
};
mln_foreach
_new
(
auto
p
,
f
.
domain
())
mln_foreach
(
auto
p
,
f
.
domain
())
{
site_t
py
=
{
static_cast
<
double
>
(
p
.
x
()),
static_cast
<
double
>
(
p
.
y
())};
value_t
vy
=
f
(
p
).
as_vec
();
...
...
pylene/include/mln/core/algorithm/paste.hpp
View file @
177e8037
...
...
@@ -63,7 +63,7 @@ namespace mln
template
<
class
InputImage
,
class
InputRange
,
class
OutputImage
>
void
paste_unsafe
(
InputImage
src
,
InputRange
roi
,
OutputImage
dest
)
{
mln_foreach
_new
(
auto
p
,
roi
)
mln_foreach
(
auto
p
,
roi
)
dest
.
at
(
p
)
=
src
.
at
(
p
);
}
}
...
...
@@ -85,7 +85,7 @@ namespace mln
}
else
{
mln_foreach
_new
(
auto
p
,
roi
)
mln_foreach
(
auto
p
,
roi
)
dest
(
p
)
=
src
(
p
);
}
}
...
...
pylene/include/mln/core/algorithm/sort.hpp
View file @
177e8037
...
...
@@ -79,7 +79,7 @@ namespace mln
sort_compute_cumulated_histogram
(
input
,
histogram
,
nvalues
,
proj
);
auto
out
=
::
ranges
::
begin
(
rng
);
mln_foreach
_new
(
auto
px
,
input
.
pixels
())
mln_foreach
(
auto
px
,
input
.
pixels
())
{
std
::
ptrdiff_t
pos
=
histogram
[
proj
(
px
.
val
())]
++
;
if
constexpr
(
use_p
)
...
...
@@ -98,7 +98,7 @@ namespace mln
// Copy to container
{
auto
it
=
::
ranges
::
begin
(
rng
);
mln_foreach
_new
(
auto
px
,
input
.
pixels
())
mln_foreach
(
auto
px
,
input
.
pixels
())
{
if
constexpr
(
use_p
)
*
it
=
px
.
point
();
...
...
pylene/include/mln/core/range/foreach.hpp
View file @
177e8037
...
...
@@ -19,7 +19,7 @@
/// \code
/// mln_foreach((auto [a,b]), multispan)
/// \endcode
#define mln_foreach
_new
(PROTECTED_DECL, RNG) \
#define mln_foreach(PROTECTED_DECL, RNG)
\
if (bool __mln_has_been_broken = false; false) \
{ \
} \
...
...
pylene/include/mln/io/imprint.hpp
View file @
177e8037
...
...
@@ -84,7 +84,7 @@ namespace mln::io
template
<
class
I
>
void
imprint
(
I
&&
image
,
...)
{
mln_foreach
_new
(
auto
px
,
image
.
pixels
())
mln_foreach
(
auto
px
,
image
.
pixels
())
fmt
::
print
(
"{{{},{}}}
\n
"
,
px
.
point
(),
px
.
val
());
}
/// \}
...
...
pylene/include/mln/labeling/accumulate.hpp
View file @
177e8037
...
...
@@ -45,7 +45,7 @@ namespace mln::labeling
{
mln_foreach
_new
(
auto
px
,
lbl_input
.
pixels
())
mln_foreach
(
auto
px
,
lbl_input
.
pixels
())
{
int
lbl
=
px
.
val
();
assert
(
0
<=
lbl
&&
lbl
<=
nlabel
);
...
...
@@ -77,7 +77,7 @@ namespace mln::labeling
{
auto
zz
=
mln
::
ranges
::
view
::
zip
(
lbl_input
.
values
(),
values
.
values
());
mln_foreach
_new
((
auto
[
lbl
,
v
]),
zz
)
mln_foreach
((
auto
[
lbl
,
v
]),
zz
)
{
assert
(
0
<=
lbl
&&
lbl
<=
nlabel
);
vec_acc
[
lbl
].
take
(
v
);
...
...
pylene/include/mln/labeling/blobs.hpp
View file @
177e8037
...
...
@@ -41,7 +41,7 @@ namespace mln::labeling
mln
::
extension
::
fill
(
out
,
LBL_MAX
);
mln_foreach
_new
(
auto
p
,
ima
.
domain
())
mln_foreach
(
auto
p
,
ima
.
domain
())
{
if
(
!
ima
(
p
)
||
out
(
p
)
>
0
)
continue
;
...
...
@@ -84,7 +84,7 @@ namespace mln::labeling
mln
::
extension
::
fill
(
out
,
LBL_MAX
);
auto
dom
=
ima
.
domain
();
mln_foreach
_new
(
auto
p
,
dom
)
mln_foreach
(
auto
p
,
dom
)
{
if
(
!
ima
(
p
)
||
out
(
p
)
>
0
)
continue
;
...
...
pylene/include/mln/labeling/chamfer_distance_transform.hpp
View file @
177e8037
...
...
@@ -62,7 +62,7 @@ namespace mln::labeling
// Forward scan
{
auto
zz
=
mln
::
ranges
::
view
::
zip
(
input
.
pixels
(),
output
.
pixels
());
mln_foreach
_new
((
auto
[
pxin
,
pxout
]),
zz
)
mln_foreach
((
auto
[
pxin
,
pxout
]),
zz
)
{
if
(
!
pxin
.
val
())
{
...
...
@@ -80,7 +80,7 @@ namespace mln::labeling
// Backward
{
auto
zz
=
mln
::
ranges
::
view
::
zip
(
input
.
pixels
(),
output
.
pixels
());
mln_foreach
_new
((
auto
[
pxin
,
pxout
]),
mln
::
ranges
::
view
::
reverse
(
zz
))
mln_foreach
((
auto
[
pxin
,
pxout
]),
mln
::
ranges
::
view
::
reverse
(
zz
))
{
if
(
!
pxin
.
val
())
continue
;
...
...
pylene/include/mln/labeling/local_extrema.hpp
View file @
177e8037
...
...
@@ -57,7 +57,7 @@ namespace mln::labeling
{
// Forward scan
mln_foreach
_new
(
auto
p
,
input
.
domain
())
mln_foreach
(
auto
p
,
input
.
domain
())
{
auto
fp
=
input
(
p
);
...
...
@@ -102,7 +102,7 @@ namespace mln::labeling
int
n_label
=
0
;
// Labelisation
{
mln_foreach
_new
(
auto
pxOut
,
output
.
pixels
())
mln_foreach
(
auto
pxOut
,
output
.
pixels
())
{
if
(
pxOut
.
val
())
{
...
...
pylene/include/mln/labeling/rag.hpp
View file @
177e8037
...
...
@@ -59,7 +59,7 @@ namespace mln::labeling
int
nlabel
=
0
;
// 1. Push labelize CC and add border pixel in queue
mln_foreach
_new
(
auto
p
,
dom
)
mln_foreach
(
auto
p
,
dom
)
{
if
(
!
ima
(
p
)
||
out
(
p
)
>
0
)
continue
;
...
...
pylene/include/mln/morpho/alphatree.hpp
View file @
177e8037
...
...
@@ -52,7 +52,7 @@ namespace mln::morpho
std
::
size_t
alphatree_create_nodemap
(
I
node_map
,
J
zpar
)
{
std
::
size_t
node_count
=
0
;
mln_foreach
_new
(
auto
px
,
node_map
.
pixels
())
mln_foreach
(
auto
px
,
node_map
.
pixels
())
{
auto
p
=
px
.
point
();
auto
rp
=
canvas
::
impl
::
zfindroot
(
zpar
,
p
);
...
...
@@ -108,7 +108,7 @@ namespace mln::morpho
void
alphatree_compute_edges
(
I
input
,
N
nbh
,
F
distance
,
std
::
vector
<
E
>&
edges
)
{
auto
dom
=
input
.
domain
();
mln_foreach
_new
(
auto
p
,
dom
)
mln_foreach
(
auto
p
,
dom
)
{
for
(
auto
n
:
nbh
.
after
(
p
))
if
(
dom
.
has
(
n
))
...
...
pylene/include/mln/morpho/canvas/unionfind.hpp
View file @
177e8037
...
...
@@ -182,7 +182,7 @@ namespace mln::morpho::canvas
template
<
class
I
>
[[
gnu
::
noinline
]]
void
union_find_init_par
(
I
par
)
noexcept
{
mln_foreach
_new
(
auto
px
,
par
.
pixels
())
mln_foreach
(
auto
px
,
par
.
pixels
())
px
.
val
()
=
px
.
point
();
}
...
...
pylene/include/mln/morpho/component_tree.hpp
View file @
177e8037
...
...
@@ -167,7 +167,7 @@ namespace mln::morpho
template
<
class
I
,
class
F
>
void
component_tree
<
void
>::
update_node_map
(
I
node_map
,
F
pred
)
const
{
mln_foreach
_new
(
auto
&
id
,
node_map
.
values
())
mln_foreach
(
auto
&
id
,
node_map
.
values
())
{
if
(
id
>
0
&&
!
pred
(
id
))
id
=
this
->
parent
[
id
];
...
...
@@ -288,7 +288,7 @@ namespace mln::morpho
std
::
vector
<
decltype
(
a
)
>
attr
(
parent
.
size
(),
a
);
// Accumulate for each point
mln_foreach
_new
(
auto
px
,
node_map
.
pixels
())
mln_foreach
(
auto
px
,
node_map
.
pixels
())
attr
[
px
.
val
()].
take
(
px
.
point
());
...
...
@@ -322,7 +322,7 @@ namespace mln::morpho
// Accumulate for each point
auto
zz
=
mln
::
view
::
zip
(
node_map
,
input
);
mln_foreach
_new
((
auto
[
node_id
,
val
]),
zz
.
values
())
mln_foreach
((
auto
[
node_id
,
val
]),
zz
.
values
())
attr
[
node_id
].
take
(
val
);
...
...
@@ -355,7 +355,7 @@ namespace mln::morpho
std
::
vector
<
decltype
(
a
)
>
attr
(
parent
.
size
(),
a
);
// Accumulate for each point
mln_foreach
_new
(
auto
px
,
values
.
pixels
())
mln_foreach
(
auto
px
,
values
.
pixels
())
attr
[
node_map
(
px
.
point
())].
take
(
px
);
...
...
@@ -383,7 +383,7 @@ namespace mln::morpho
image_ch_value_t
<
I
,
V
>
out
=
imchvalue
<
V
>
(
node_map
);
auto
zz
=
mln
::
view
::
zip
(
node_map
,
out
);
mln_foreach
_new
((
auto
&&
[
node_id
,
val
]),
zz
.
values
())
mln_foreach
((
auto
&&
[
node_id
,
val
]),
zz
.
values
())
val
=
values
[
node_id
];
return
out
;
...
...
pylene/include/mln/morpho/watershed.hpp
View file @
177e8037
...
...
@@ -48,7 +48,7 @@ namespace mln::morpho
{
output
.
extension
().
fill
(
kWaterline
);
mln_foreach
_new
(
auto
px
,
output
.
pixels
())
mln_foreach
(
auto
px
,
output
.
pixels
())
{
// Not a local minimum => early exit
if
(
px
.
val
()
!=
0
)
...
...
pylene/src/io/imprint.cpp
View file @
177e8037
...
...
@@ -7,7 +7,7 @@ namespace mln::io::internal
{
// Compute column width
int
width
=
0
;
mln_foreach
_new
(
auto
p
,
roi
)
mln_foreach
(
auto
p
,
roi
)
{
int
w
=
static_cast
<
int
>
(
fmter
.
formatted_size
(
p
));
if
(
width
<
w
)
...
...
@@ -28,7 +28,7 @@ namespace mln::io::internal
{
// Compute column width
int
width
=
0
;
mln_foreach
_new
(
auto
p
,
roi
)
mln_foreach
(
auto
p
,
roi
)
{
int
w
=
static_cast
<
int
>
(
fmter
.
formatted_size
(
p
));
if
(
width
<
w
)
...
...
tests/core/image/view/extended.cpp
View file @
177e8037
...
...
@@ -20,7 +20,7 @@ TEST(View, extended)
{
auto
zz
=
mln
::
view
::
zip
(
ima
,
x
);
mln_foreach
_new
(
auto
px
,
zz
.
pixels
())
mln_foreach
(
auto
px
,
zz
.
pixels
())
{
auto
[
v1
,
v2
]
=
px
.
val
();
ASSERT_EQ
(
v1
,
v2
);
...
...
@@ -28,7 +28,7 @@ TEST(View, extended)
}
{
mln_foreach
_new
(
auto
p
,
x
.
pixels
())
mln_foreach
(
auto
p
,
x
.
pixels
())
for
(
auto
q
:
mln
::
c8
(
p
))
if
(
!
x
.
domain
().
has
(
q
.
point
()))
ASSERT_EQ
(
q
.
val
(),
69
);
...
...
Prev
1
2
Next
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