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
0e1775af
Commit
0e1775af
authored
10 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'github/master'
parents
5e50d333
0e375af1
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
core/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
+51
-6
51 additions, 6 deletions
core/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
with
51 additions
and
6 deletions
core/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
+
51
−
6
View file @
0e1775af
...
...
@@ -7,6 +7,9 @@ import java.io.File;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
mpicbg.spim.data.generic.sequence.AbstractSequenceDescription
;
import
mpicbg.spim.data.generic.sequence.BasicViewSetup
;
...
...
@@ -370,13 +373,55 @@ public class Hdf5ImageLoader extends AbstractViewerImgLoader< UnsignedShortType,
// copy unsigned short img to float img
final
FloatType
f
=
new
FloatType
();
final
Img
<
FloatType
>
floatImg
=
net
.
imglib2
.
util
.
Util
.
getArrayOrCellImgFactory
(
ushortImg
,
f
).
create
(
ushortImg
,
f
);
final
Cursor
<
UnsignedShortType
>
in
=
Views
.
iterable
(
ushortImg
).
localizingCursor
();
final
RandomAccess
<
FloatType
>
out
=
floatImg
.
randomAccess
();
while
(
in
.
hasNext
()
)
// set up executor service
final
int
numProcessors
=
Runtime
.
getRuntime
().
availableProcessors
();
final
ExecutorService
taskExecutor
=
Executors
.
newFixedThreadPool
(
numProcessors
);
final
ArrayList
<
Callable
<
Boolean
>
>
tasks
=
new
ArrayList
<
Callable
<
Boolean
>
>();
// set up all threads
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
;
tasks
.
add
(
new
Callable
<
Boolean
>()
{
@Override
public
Boolean
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
true
;
}
});
}
try
{
// invokeAll() returns when all tasks are complete
taskExecutor
.
invokeAll
(
tasks
);
}
catch
(
final
InterruptedException
e
)
{
in
.
next
();
out
.
setPosition
(
in
);
out
.
get
().
set
(
in
.
get
().
getRealFloat
()
);
return
null
;
}
if
(
normalize
)
...
...
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