Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Core_Extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
BioinformaticDataCompression
BigDataViewer_Core_Extension
Commits
6ff3f2f5
Commit
6ff3f2f5
authored
10 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
move utility functions for computing transformed bounding boxes to bdv.util
parent
da3f0baf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/java/bdv/tools/crop/CropImgLoader.java
+3
-52
3 additions, 52 deletions
core/src/main/java/bdv/tools/crop/CropImgLoader.java
core/src/main/java/bdv/util/IntervalBoundingBox.java
+61
-0
61 additions, 0 deletions
core/src/main/java/bdv/util/IntervalBoundingBox.java
with
64 additions
and
52 deletions
core/src/main/java/bdv/tools/crop/CropImgLoader.java
+
3
−
52
View file @
6ff3f2f5
...
@@ -2,26 +2,24 @@ package bdv.tools.crop;
...
@@ -2,26 +2,24 @@ package bdv.tools.crop;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
mpicbg.spim.data.generic.sequence.BasicImgLoader
;
import
mpicbg.spim.data.generic.sequence.BasicImgLoader
;
import
mpicbg.spim.data.sequence.ImgLoader
;
import
mpicbg.spim.data.sequence.ImgLoader
;
import
mpicbg.spim.data.sequence.ViewId
;
import
mpicbg.spim.data.sequence.ViewId
;
import
net.imglib2.FinalRealInterval
;
import
net.imglib2.Interval
;
import
net.imglib2.Interval
;
import
net.imglib2.Pair
;
import
net.imglib2.Pair
;
import
net.imglib2.RandomAccessibleInterval
;
import
net.imglib2.RandomAccessibleInterval
;
import
net.imglib2.RealInterval
;
import
net.imglib2.RealInterval
;
import
net.imglib2.RealLocalizable
;
import
net.imglib2.RealLocalizable
;
import
net.imglib2.RealPoint
;
import
net.imglib2.RealPoint
;
import
net.imglib2.iterator.LocalizingZeroMinIntervalIterator
;
import
net.imglib2.realtransform.AffineTransform3D
;
import
net.imglib2.realtransform.AffineTransform3D
;
import
net.imglib2.type.numeric.NumericType
;
import
net.imglib2.type.numeric.NumericType
;
import
net.imglib2.type.numeric.integer.UnsignedShortType
;
import
net.imglib2.type.numeric.integer.UnsignedShortType
;
import
net.imglib2.util.Intervals
;
import
net.imglib2.util.Intervals
;
import
net.imglib2.util.ValuePair
;
import
net.imglib2.util.ValuePair
;
import
net.imglib2.view.Views
;
import
net.imglib2.view.Views
;
import
bdv.util.IntervalBoundingBox
;
import
bdv.viewer.Source
;
import
bdv.viewer.Source
;
/**
/**
...
@@ -115,14 +113,14 @@ public class CropImgLoader implements BasicImgLoader< UnsignedShortType >
...
@@ -115,14 +113,14 @@ public class CropImgLoader implements BasicImgLoader< UnsignedShortType >
cropToSource
.
concatenate
(
cropToGlobal
);
cropToSource
.
concatenate
(
cropToGlobal
);
final
ArrayList
<
RealPoint
>
sourceCorners
=
new
ArrayList
<
RealPoint
>();
final
ArrayList
<
RealPoint
>
sourceCorners
=
new
ArrayList
<
RealPoint
>();
for
(
final
RealLocalizable
corner
:
getCorners
(
interval
)
)
for
(
final
RealLocalizable
corner
:
IntervalBoundingBox
.
getCorners
(
interval
)
)
{
{
final
RealPoint
sourceCorner
=
new
RealPoint
(
n
);
final
RealPoint
sourceCorner
=
new
RealPoint
(
n
);
cropToSource
.
apply
(
corner
,
sourceCorner
);
cropToSource
.
apply
(
corner
,
sourceCorner
);
sourceCorners
.
add
(
sourceCorner
);
sourceCorners
.
add
(
sourceCorner
);
}
}
final
RandomAccessibleInterval
<
T
>
sourceImg
=
source
.
getSource
(
timepoint
,
0
);
final
RandomAccessibleInterval
<
T
>
sourceImg
=
source
.
getSource
(
timepoint
,
0
);
final
Interval
cropBoundingBox
=
Intervals
.
smallestContainingInterval
(
getBoundingBox
(
sourceCorners
)
);
final
Interval
cropBoundingBox
=
Intervals
.
smallestContainingInterval
(
IntervalBoundingBox
.
getBoundingBox
(
sourceCorners
)
);
Interval
sourceInterval
=
Intervals
.
intersect
(
cropBoundingBox
,
sourceImg
);
Interval
sourceInterval
=
Intervals
.
intersect
(
cropBoundingBox
,
sourceImg
);
final
RandomAccessibleInterval
<
T
>
croppedSourceImg
;
final
RandomAccessibleInterval
<
T
>
croppedSourceImg
;
...
@@ -146,51 +144,4 @@ public class CropImgLoader implements BasicImgLoader< UnsignedShortType >
...
@@ -146,51 +144,4 @@ public class CropImgLoader implements BasicImgLoader< UnsignedShortType >
return
new
ValuePair
<
RandomAccessibleInterval
<
T
>,
AffineTransform3D
>(
croppedSourceImg
,
croppedSourceTransform
);
return
new
ValuePair
<
RandomAccessibleInterval
<
T
>,
AffineTransform3D
>(
croppedSourceImg
,
croppedSourceTransform
);
}
}
/**
* get bounding box of a list of points.
*/
public
static
<
P
extends
RealLocalizable
>
RealInterval
getBoundingBox
(
final
List
<
P
>
points
)
{
assert
!
points
.
isEmpty
();
final
P
p0
=
points
.
get
(
0
);
final
int
n
=
p0
.
numDimensions
();
final
double
[]
min
=
new
double
[
n
];
p0
.
localize
(
min
);
final
double
[]
max
=
min
.
clone
();
for
(
final
P
point
:
points
)
{
for
(
int
d
=
0
;
d
<
n
;
++
d
)
{
final
double
p
=
point
.
getDoublePosition
(
d
);
if
(
p
<
min
[
d
])
min
[
d
]
=
p
;
else
if
(
p
>
max
[
d
])
max
[
d
]
=
p
;
}
}
return
new
FinalRealInterval
(
min
,
max
);
}
/**
* get "corners" of an interval as a list of points.
*/
public
static
List
<
RealLocalizable
>
getCorners
(
final
RealInterval
interval
)
{
final
ArrayList
<
RealLocalizable
>
corners
=
new
ArrayList
<
RealLocalizable
>();
final
int
n
=
interval
.
numDimensions
();
final
int
[]
tmp
=
new
int
[
n
];
Arrays
.
fill
(
tmp
,
2
);
final
LocalizingZeroMinIntervalIterator
i
=
new
LocalizingZeroMinIntervalIterator
(
tmp
);
while
(
i
.
hasNext
()
)
{
i
.
fwd
();
final
RealPoint
p
=
new
RealPoint
(
n
);
for
(
int
d
=
0
;
d
<
n
;
++
d
)
p
.
setPosition
(
i
.
getIntPosition
(
d
)
==
0
?
interval
.
realMin
(
d
)
:
interval
.
realMax
(
d
),
d
);
corners
.
add
(
p
);
}
return
corners
;
}
}
}
This diff is collapsed.
Click to expand it.
core/src/main/java/bdv/util/IntervalBoundingBox.java
0 → 100644
+
61
−
0
View file @
6ff3f2f5
package
bdv.util
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
net.imglib2.FinalRealInterval
;
import
net.imglib2.RealInterval
;
import
net.imglib2.RealLocalizable
;
import
net.imglib2.RealPoint
;
import
net.imglib2.iterator.LocalizingZeroMinIntervalIterator
;
public
class
IntervalBoundingBox
{
/**
* get bounding box of a list of points.
*/
public
static
<
P
extends
RealLocalizable
>
RealInterval
getBoundingBox
(
final
List
<
P
>
points
)
{
assert
!
points
.
isEmpty
();
final
P
p0
=
points
.
get
(
0
);
final
int
n
=
p0
.
numDimensions
();
final
double
[]
min
=
new
double
[
n
];
p0
.
localize
(
min
);
final
double
[]
max
=
min
.
clone
();
for
(
final
P
point
:
points
)
{
for
(
int
d
=
0
;
d
<
n
;
++
d
)
{
final
double
p
=
point
.
getDoublePosition
(
d
);
if
(
p
<
min
[
d
])
min
[
d
]
=
p
;
else
if
(
p
>
max
[
d
])
max
[
d
]
=
p
;
}
}
return
new
FinalRealInterval
(
min
,
max
);
}
/**
* get "corners" of an interval as a list of points.
*/
public
static
List
<
RealLocalizable
>
getCorners
(
final
RealInterval
interval
)
{
final
ArrayList
<
RealLocalizable
>
corners
=
new
ArrayList
<
RealLocalizable
>();
final
int
n
=
interval
.
numDimensions
();
final
int
[]
tmp
=
new
int
[
n
];
Arrays
.
fill
(
tmp
,
2
);
final
LocalizingZeroMinIntervalIterator
i
=
new
LocalizingZeroMinIntervalIterator
(
tmp
);
while
(
i
.
hasNext
()
)
{
i
.
fwd
();
final
RealPoint
p
=
new
RealPoint
(
n
);
for
(
int
d
=
0
;
d
<
n
;
++
d
)
p
.
setPosition
(
i
.
getIntPosition
(
d
)
==
0
?
interval
.
realMin
(
d
)
:
interval
.
realMax
(
d
),
d
);
corners
.
add
(
p
);
}
return
corners
;
}
}
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