Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
c084808e
Commit
c084808e
authored
12 years ago
by
Andreas Schenk
Committed by
Marco Biasini
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fixed discrete shrink algorithm for half frequency domain
parent
0b597805
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/img/alg/src/discrete_shrink.cc
+21
-19
21 additions, 19 deletions
modules/img/alg/src/discrete_shrink.cc
with
21 additions
and
19 deletions
modules/img/alg/src/discrete_shrink.cc
+
21
−
19
View file @
c084808e
...
...
@@ -49,6 +49,7 @@ void do_shrink(const ImageStateImpl<T,D>& isi, T& dest, const Extent& inner_ext)
T
sum
(
0
);
Real
count
=
0.0
;
for
(
ExtentIterator
bit
(
inner_ext
);
!
bit
.
AtEnd
();
++
bit
)
{
LOG_VERBOSE
(
"inner extent point:"
<<
Point
(
bit
)
<<
","
<<
isi
.
GetExtent
().
Contains
(
Point
(
bit
)));
sum
+=
isi
.
Value
(
bit
);
count
+=
1.0
;
}
...
...
@@ -61,18 +62,27 @@ void do_shrink(const ImageStateImpl<T,D>& isi, T& dest, const Extent& inner_ext)
template
<
typename
T
,
class
D
>
ImageStateBasePtr
DiscreteShrinkFnc
::
VisitState
(
const
ImageStateImpl
<
T
,
D
>&
isi
)
const
{
Size
size
(
isi
.
GetExtent
().
GetSize
());
Point
start
(
isi
.
GetExtent
().
GetStart
());
Size
size
(
isi
.
Get
Logical
Extent
().
GetSize
());
Point
start
(
isi
.
Get
Logical
Extent
().
GetStart
());
Size
newsize
;
div_t
dt
;
dt
=
div
(
static_cast
<
int
>
(
size
[
0
]),
bs_
[
0
]);
newsize
[
0
]
=
dt
.
quot
+
((
dt
.
rem
>
0
)
?
1
:
0
);
dt
=
div
(
static_cast
<
int
>
(
size
[
1
]),
bs_
[
1
]);
newsize
[
1
]
=
dt
.
quot
+
((
dt
.
rem
>
0
)
?
1
:
0
);
dt
=
div
(
static_cast
<
int
>
(
size
[
2
]),
bs_
[
2
]);
newsize
[
2
]
=
dt
.
quot
+
((
dt
.
rem
>
0
)
?
1
:
0
);
dt
=
div
(
static_cast
<
int
>
(
size
[
0
]),
bs_
[
0
]);
newsize
[
0
]
=
dt
.
quot
+
((
dt
.
rem
>
0
)
?
1
:
0
);
dt
=
div
(
static_cast
<
int
>
(
size
[
1
]),
bs_
[
1
]);
newsize
[
1
]
=
dt
.
quot
+
((
dt
.
rem
>
0
)
?
1
:
0
);
dt
=
div
(
static_cast
<
int
>
(
size
[
2
]),
bs_
[
2
]);
newsize
[
2
]
=
dt
.
quot
+
((
dt
.
rem
>
0
)
?
1
:
0
);
Extent
new_ext
(
newsize
);
Point
newstart
;
LOG_DEBUG
(
"extent of shrunken image"
<<
isi
.
GetExtent
()
<<
" "
<<
new_ext
);
dt
=
div
(
start
[
0
],
bs_
[
0
]);
newstart
[
0
]
=
dt
.
quot
;
dt
=
div
(
start
[
1
],
bs_
[
1
]);
newstart
[
1
]
=
dt
.
quot
;
dt
=
div
(
start
[
2
],
bs_
[
2
]);
newstart
[
2
]
=
dt
.
quot
;
new_ext
.
Shift
(
newstart
);
LOG_DEBUG
(
"extent of shrunken image"
<<
isi
.
GetExtent
()
<<
" "
<<
new_ext
<<
new_ext
.
GetEnd
());
geom
::
Vec3
ao
=
isi
.
GetAbsoluteOrigin
();
...
...
@@ -80,26 +90,18 @@ ImageStateBasePtr DiscreteShrinkFnc::VisitState(const ImageStateImpl<T,D>& isi)
new_ps
.
SetExtent
(
new_ext
);
typename
ImageStateImpl
<
T
,
D
>::
SharedPtrType
ni
(
new
ImageStateImpl
<
T
,
D
>
(
new_ext
,
new_ps
));
ni
->
SetAbsoluteOrigin
(
ao
);
ni
->
GetSampling
().
SetPixelSampling
(
CompMultiply
(
ni
->
GetSampling
().
GetPixelSampling
(),
Vec3
(
bs_
[
0
],
bs_
[
1
],
bs_
[
2
])));
for
(
ExtentIterator
it
(
n
ew_ext
);
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
n
i
->
GetExtent
(),
ni
->
GetDomain
()
);
!
it
.
AtEnd
();
++
it
)
{
Point
t
(
it
[
0
]
*
bs_
[
0
],
it
[
1
]
*
bs_
[
1
],
it
[
2
]
*
bs_
[
2
]);
Extent
inner_ext
=
Overlap
(
Extent
(
t
+
start
,
bs_
),
isi
.
GetExtent
());
Extent
inner_ext
=
Overlap
(
Extent
(
t
,
bs_
),
isi
.
GetExtent
());
do_shrink
(
isi
,
ni
->
Value
(
it
),
inner_ext
);
}
Point
newstart
;
dt
=
div
(
start
[
0
],
bs_
[
0
]);
newstart
[
0
]
=
dt
.
quot
;
dt
=
div
(
start
[
1
],
bs_
[
1
]);
newstart
[
1
]
=
dt
.
quot
;
dt
=
div
(
start
[
2
],
bs_
[
2
]);
newstart
[
2
]
=
dt
.
quot
;
ni
->
SetAbsoluteOrigin
(
ao
);
ni
->
SetSpatialOrigin
(
newstart
);
ni
->
GetSampling
().
SetPixelSampling
(
CompMultiply
(
ni
->
GetSampling
().
GetPixelSampling
(),
Vec3
(
bs_
[
0
],
bs_
[
1
],
bs_
[
2
])));
return
ni
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment