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
6cb99a78
Commit
6cb99a78
authored
5 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
Remove Hdf5ImageLoader.getFloatImage(), use default implementation instead
parent
3f95955d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
+0
-140
0 additions, 140 deletions
src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
with
0 additions
and
140 deletions
src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
+
0
−
140
View file @
6cb99a78
...
...
@@ -38,8 +38,6 @@ import java.util.Arrays;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
bdv.AbstractViewerSetupImgLoader
;
import
bdv.ViewerImgLoader
;
...
...
@@ -63,17 +61,13 @@ import net.imglib2.Cursor;
import
net.imglib2.Dimensions
;
import
net.imglib2.FinalDimensions
;
import
net.imglib2.FinalInterval
;
import
net.imglib2.IterableInterval
;
import
net.imglib2.RandomAccess
;
import
net.imglib2.RandomAccessibleInterval
;
import
net.imglib2.cache.queue.BlockingFetchQueues
;
import
net.imglib2.cache.queue.FetcherThreads
;
import
net.imglib2.cache.volatiles.CacheHints
;
import
net.imglib2.cache.volatiles.LoadingStrategy
;
import
net.imglib2.img.Img
;
import
net.imglib2.img.ImgFactory
;
import
net.imglib2.img.NativeImg
;
import
net.imglib2.img.array.ArrayImgFactory
;
import
net.imglib2.img.array.ArrayImgs
;
import
net.imglib2.img.basictypeaccess.array.ShortArray
;
import
net.imglib2.img.cell.Cell
;
...
...
@@ -83,7 +77,6 @@ import net.imglib2.img.cell.CellImgFactory;
import
net.imglib2.realtransform.AffineTransform3D
;
import
net.imglib2.type.NativeType
;
import
net.imglib2.type.numeric.integer.UnsignedShortType
;
import
net.imglib2.type.numeric.real.FloatType
;
import
net.imglib2.type.volatiles.VolatileUnsignedShortType
;
import
net.imglib2.util.Intervals
;
import
net.imglib2.view.Views
;
...
...
@@ -363,27 +356,6 @@ public class Hdf5ImageLoader implements ViewerImgLoader, MultiResolutionImgLoade
}
}
/**
* normalize img to 0...1
*/
protected
static
void
normalize
(
final
IterableInterval
<
FloatType
>
img
)
{
float
currentMax
=
img
.
firstElement
().
get
();
float
currentMin
=
currentMax
;
for
(
final
FloatType
t
:
img
)
{
final
float
f
=
t
.
get
();
if
(
f
>
currentMax
)
currentMax
=
f
;
else
if
(
f
<
currentMin
)
currentMin
=
f
;
}
final
float
scale
=
(
float
)
(
1.0
/
(
currentMax
-
currentMin
)
);
for
(
final
FloatType
t
:
img
)
t
.
set
(
(
t
.
get
()
-
currentMin
)
*
scale
);
}
@Override
public
SetupImgLoader
getSetupImgLoader
(
final
int
setupId
)
{
...
...
@@ -555,118 +527,6 @@ public class Hdf5ImageLoader implements ViewerImgLoader, MultiResolutionImgLoade
return
Views
.
interval
(
new
ConstantRandomAccessible
<>(
constant
,
3
),
new
FinalInterval
(
d
)
);
}
@Override
public
RandomAccessibleInterval
<
FloatType
>
getFloatImage
(
final
int
timepointId
,
final
boolean
normalize
,
final
ImgLoaderHint
...
hints
)
{
return
getFloatImage
(
timepointId
,
0
,
normalize
,
hints
);
}
@Override
public
RandomAccessibleInterval
<
FloatType
>
getFloatImage
(
final
int
timepointId
,
final
int
level
,
final
boolean
normalize
,
final
ImgLoaderHint
...
hints
)
{
final
RandomAccessibleInterval
<
UnsignedShortType
>
ushortImg
=
getImage
(
timepointId
,
level
,
hints
);
// copy unsigned short img to float img
// create float img
final
FloatType
f
=
new
FloatType
();
final
ImgFactory
<
FloatType
>
imgFactory
;
if
(
Intervals
.
numElements
(
ushortImg
)
<=
Integer
.
MAX_VALUE
)
{
imgFactory
=
new
ArrayImgFactory
<>(
f
);
}
else
{
final
long
[]
dimsLong
=
new
long
[
ushortImg
.
numDimensions
()
];
ushortImg
.
dimensions
(
dimsLong
);
final
int
[]
cellDimensions
=
computeCellDimensions
(
dimsLong
,
mipmapInfo
.
getSubdivisions
()[
level
]
);
imgFactory
=
new
CellImgFactory
<>(
f
,
cellDimensions
);
}
final
Img
<
FloatType
>
floatImg
=
imgFactory
.
create
(
ushortImg
);
// set up executor service
final
int
numProcessors
=
Runtime
.
getRuntime
().
availableProcessors
();
final
ExecutorService
taskExecutor
=
Executors
.
newFixedThreadPool
(
numProcessors
);
final
ArrayList
<
Callable
<
Void
>
>
tasks
=
new
ArrayList
<>();
// set up all tasks
final
int
numPortions
=
numProcessors
*
2
;
final
long
threadChunkSize
=
floatImg
.
size
()
/
numPortions
;
final
long
threadChunkMod
=
floatImg
.
size
()
%
numPortions
;
for
(
int
portionID
=
0
;
portionID
<
numPortions
;
++
portionID
)
{
// move to the starting position of the current thread
final
long
startPosition
=
portionID
*
threadChunkSize
;
// the last thread may has to run longer if the number of pixels cannot be divided by the number of threads
final
long
loopSize
=
(
portionID
==
numPortions
-
1
)
?
threadChunkSize
+
threadChunkMod
:
threadChunkSize
;
if
(
Views
.
iterable
(
ushortImg
).
iterationOrder
().
equals
(
floatImg
.
iterationOrder
()
)
)
{
tasks
.
add
(
new
Callable
<
Void
>()
{
@Override
public
Void
call
()
throws
Exception
{
final
Cursor
<
UnsignedShortType
>
in
=
Views
.
iterable
(
ushortImg
).
cursor
();
final
Cursor
<
FloatType
>
out
=
floatImg
.
cursor
();
in
.
jumpFwd
(
startPosition
);
out
.
jumpFwd
(
startPosition
);
for
(
long
j
=
0
;
j
<
loopSize
;
++
j
)
out
.
next
().
set
(
in
.
next
().
getRealFloat
()
);
return
null
;
}
}
);
}
else
{
tasks
.
add
(
new
Callable
<
Void
>()
{
@Override
public
Void
call
()
throws
Exception
{
final
Cursor
<
UnsignedShortType
>
in
=
Views
.
iterable
(
ushortImg
).
localizingCursor
();
final
RandomAccess
<
FloatType
>
out
=
floatImg
.
randomAccess
();
in
.
jumpFwd
(
startPosition
);
for
(
long
j
=
0
;
j
<
loopSize
;
++
j
)
{
final
UnsignedShortType
vin
=
in
.
next
();
out
.
setPosition
(
in
);
out
.
get
().
set
(
vin
.
getRealFloat
()
);
}
return
null
;
}
}
);
}
}
try
{
// invokeAll() returns when all tasks are complete
taskExecutor
.
invokeAll
(
tasks
);
taskExecutor
.
shutdown
();
}
catch
(
final
InterruptedException
e
)
{
return
null
;
}
if
(
normalize
)
// normalize the image to 0...1
normalize
(
floatImg
);
return
floatImg
;
}
public
MipmapInfo
getMipmapInfo
()
{
return
mipmapInfo
;
...
...
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