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
928e1424
Commit
928e1424
authored
11 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
CatmaidImageLoader is ARGBType now
parent
1c20bed3
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
src/main/java/bdv/img/catmaid/CatmaidImageLoader.java
+36
-35
36 additions, 35 deletions
src/main/java/bdv/img/catmaid/CatmaidImageLoader.java
src/main/java/bdv/img/catmaid/CatmaidVolatileIntArrayLoader.java
+99
-0
99 additions, 0 deletions
...n/java/bdv/img/catmaid/CatmaidVolatileIntArrayLoader.java
with
135 additions
and
35 deletions
src/main/java/bdv/img/catmaid/CatmaidImageLoader.java
+
36
−
35
View file @
928e1424
...
...
@@ -5,12 +5,12 @@ import java.io.File;
import
mpicbg.spim.data.View
;
import
net.imglib2.RandomAccessibleInterval
;
import
net.imglib2.img.NativeImg
;
import
net.imglib2.img.basictypeaccess.volatiles.array.Volatile
Shor
tArray
;
import
net.imglib2.img.basictypeaccess.volatiles.array.Volatile
In
tArray
;
import
net.imglib2.img.cell.CellImg
;
import
net.imglib2.type.NativeType
;
import
net.imglib2.type.numeric.
integer.UnsignedShort
Type
;
import
net.imglib2.type.numeric.
ARGB
Type
;
import
net.imglib2.type.numeric.real.FloatType
;
import
net.imglib2.type.volatiles.Volatile
UnsignedShort
Type
;
import
net.imglib2.type.volatiles.Volatile
ARGB
Type
;
import
org.jdom2.Element
;
...
...
@@ -22,7 +22,7 @@ import bdv.img.cache.VolatileGlobalCellCache.LoadingStrategy;
import
bdv.img.cache.VolatileImgCells
;
import
bdv.img.cache.VolatileImgCells.CellCache
;
public
class
CatmaidImageLoader
implements
ViewerImgLoader
<
UnsignedShort
Type
,
Volatile
UnsignedShort
Type
>
public
class
CatmaidImageLoader
implements
ViewerImgLoader
<
ARGB
Type
,
Volatile
ARGB
Type
>
{
private
long
width
;
...
...
@@ -48,27 +48,28 @@ public class CatmaidImageLoader implements ViewerImgLoader< UnsignedShortType, V
private
int
[][]
blockDimensions
;
protected
VolatileGlobalCellCache
<
Volatile
Shor
tArray
>
cache
;
protected
VolatileGlobalCellCache
<
Volatile
In
tArray
>
cache
;
@Override
public
void
init
(
final
Element
elem
,
final
File
basePath
)
{
width
=
1987
;
height
=
1441
;
depth
=
460
;
width
=
Long
.
parseLong
(
elem
.
getChildText
(
"width"
)
)
;
height
=
Long
.
parseLong
(
elem
.
getChildText
(
"height"
)
)
;
depth
=
Long
.
parseLong
(
elem
.
getChildText
(
"depth"
)
)
;
resXY
=
5.6
;
resZ
=
11.2
;
resXY
=
Double
.
parseDouble
(
elem
.
getChildText
(
"resXY"
)
)
;
resZ
=
Double
.
parseDouble
(
elem
.
getChildText
(
"resZ"
)
)
;
// baseUrl = "file:/Users/pietzsch/Desktop/data/catmaid/xy/";
baseUrl
=
"http://fly.mpi-cbg.de/map/fib/aligned/xy/"
;
baseUrl
=
elem
.
getChildText
(
"baseUrl"
);
tileWidth
=
256
;
tileHeight
=
256
;
tileWidth
=
Integer
.
parseInt
(
elem
.
getChildText
(
"tileWidth"
)
)
;
tileHeight
=
Integer
.
parseInt
(
elem
.
getChildText
(
"tileHeight"
)
)
;
numScales
=
getNumScales
(
width
,
height
,
tileWidth
,
tileHeight
);
System
.
out
.
println
(
"numScales = "
+
numScales
);
final
String
numScalesString
=
elem
.
getChildText
(
"numScales"
);
if
(
numScalesString
==
null
)
numScales
=
getNumScales
(
width
,
height
,
tileWidth
,
tileHeight
);
else
numScales
=
Integer
.
parseInt
(
numScalesString
);
mipmapResolutions
=
new
double
[
numScales
][];
imageDimensions
=
new
long
[
numScales
][];
...
...
@@ -82,8 +83,8 @@ public class CatmaidImageLoader implements ViewerImgLoader< UnsignedShortType, V
}
final
int
[]
maxLevels
=
new
int
[]
{
numScales
-
1
};
cache
=
new
VolatileGlobalCellCache
<
Volatile
Shor
tArray
>(
new
CatmaidVolatile
Shor
tArrayLoader
(
baseUrl
,
tileWidth
,
tileHeight
),
1
,
1
,
numScales
,
maxLevels
,
10
);
cache
=
new
VolatileGlobalCellCache
<
Volatile
In
tArray
>(
new
CatmaidVolatile
In
tArrayLoader
(
baseUrl
,
tileWidth
,
tileHeight
),
1
,
1
,
numScales
,
maxLevels
,
10
);
}
final
static
public
int
getNumScales
(
long
width
,
long
height
,
final
long
tileWidth
,
final
long
tileHeight
)
...
...
@@ -109,25 +110,25 @@ public class CatmaidImageLoader implements ViewerImgLoader< UnsignedShortType, V
}
@Override
public
RandomAccessibleInterval
<
UnsignedShort
Type
>
getImage
(
final
View
view
)
public
RandomAccessibleInterval
<
ARGB
Type
>
getImage
(
final
View
view
)
{
return
getImage
(
view
,
0
);
}
@Override
public
RandomAccessibleInterval
<
UnsignedShort
Type
>
getImage
(
final
View
view
,
final
int
level
)
public
RandomAccessibleInterval
<
ARGB
Type
>
getImage
(
final
View
view
,
final
int
level
)
{
final
CellImg
<
UnsignedShort
Type
,
Volatile
Shor
tArray
,
VolatileCell
<
Volatile
Shor
tArray
>
>
img
=
prepareCachedImage
(
view
,
level
,
LoadingStrategy
.
BLOCKING
);
final
UnsignedShort
Type
linkedType
=
new
UnsignedShort
Type
(
img
);
final
CellImg
<
ARGB
Type
,
Volatile
In
tArray
,
VolatileCell
<
Volatile
In
tArray
>
>
img
=
prepareCachedImage
(
view
,
level
,
LoadingStrategy
.
BLOCKING
);
final
ARGB
Type
linkedType
=
new
ARGB
Type
(
img
);
img
.
setLinkedType
(
linkedType
);
return
img
;
}
@Override
public
RandomAccessibleInterval
<
Volatile
UnsignedShort
Type
>
getVolatileImage
(
final
View
view
,
final
int
level
)
public
RandomAccessibleInterval
<
Volatile
ARGB
Type
>
getVolatileImage
(
final
View
view
,
final
int
level
)
{
final
CellImg
<
Volatile
UnsignedShort
Type
,
Volatile
Shor
tArray
,
VolatileCell
<
Volatile
Shor
tArray
>
>
img
=
prepareCachedImage
(
view
,
level
,
LoadingStrategy
.
VOLATILE
);
final
Volatile
UnsignedShort
Type
linkedType
=
new
Volatile
UnsignedShort
Type
(
img
);
final
CellImg
<
Volatile
ARGB
Type
,
Volatile
In
tArray
,
VolatileCell
<
Volatile
In
tArray
>
>
img
=
prepareCachedImage
(
view
,
level
,
LoadingStrategy
.
VOLATILE
);
final
Volatile
ARGB
Type
linkedType
=
new
Volatile
ARGB
Type
(
img
);
img
.
setLinkedType
(
linkedType
);
return
img
;
}
...
...
@@ -147,16 +148,16 @@ public class CatmaidImageLoader implements ViewerImgLoader< UnsignedShortType, V
/**
* (Almost) create a {@link CellImg} backed by the cache.
* The created image needs a {@link NativeImg#setLinkedType(net.imglib2.type.Type) linked type} before it can be used.
* The type should be either {@link
UnsignedShort
Type} and {@link Volatile
UnsignedShort
Type}.
* The type should be either {@link
ARGB
Type} and {@link Volatile
ARGB
Type}.
*/
protected
<
T
extends
NativeType
<
T
>
>
CellImg
<
T
,
Volatile
Shor
tArray
,
VolatileCell
<
Volatile
Shor
tArray
>
>
prepareCachedImage
(
final
View
view
,
final
int
level
,
final
LoadingStrategy
loadingStrategy
)
protected
<
T
extends
NativeType
<
T
>
>
CellImg
<
T
,
Volatile
In
tArray
,
VolatileCell
<
Volatile
In
tArray
>
>
prepareCachedImage
(
final
View
view
,
final
int
level
,
final
LoadingStrategy
loadingStrategy
)
{
final
long
[]
dimensions
=
imageDimensions
[
level
];
final
int
[]
cellDimensions
=
blockDimensions
[
level
];
final
CellCache
<
Volatile
Shor
tArray
>
c
=
cache
.
new
VolatileCellCache
(
view
.
getTimepointIndex
(),
view
.
getSetupIndex
(),
level
,
loadingStrategy
);
final
VolatileImgCells
<
Volatile
Shor
tArray
>
cells
=
new
VolatileImgCells
<
Volatile
Shor
tArray
>(
c
,
1
,
dimensions
,
cellDimensions
);
final
CellImg
<
T
,
Volatile
Shor
tArray
,
VolatileCell
<
Volatile
Shor
tArray
>
>
img
=
new
CellImg
<
T
,
Volatile
Shor
tArray
,
VolatileCell
<
Volatile
Shor
tArray
>
>(
null
,
cells
);
final
CellCache
<
Volatile
In
tArray
>
c
=
cache
.
new
VolatileCellCache
(
view
.
getTimepointIndex
(),
view
.
getSetupIndex
(),
level
,
loadingStrategy
);
final
VolatileImgCells
<
Volatile
In
tArray
>
cells
=
new
VolatileImgCells
<
Volatile
In
tArray
>(
c
,
1
,
dimensions
,
cellDimensions
);
final
CellImg
<
T
,
Volatile
In
tArray
,
VolatileCell
<
Volatile
In
tArray
>
>
img
=
new
CellImg
<
T
,
Volatile
In
tArray
,
VolatileCell
<
Volatile
In
tArray
>
>(
null
,
cells
);
return
img
;
}
...
...
@@ -165,18 +166,18 @@ public class CatmaidImageLoader implements ViewerImgLoader< UnsignedShortType, V
return
cache
;
}
private
final
UnsignedShort
Type
type
=
new
UnsignedShort
Type
();
private
final
ARGB
Type
type
=
new
ARGB
Type
();
private
final
Volatile
UnsignedShort
Type
volatileType
=
new
Volatile
UnsignedShort
Type
();
private
final
Volatile
ARGB
Type
volatileType
=
new
Volatile
ARGB
Type
();
@Override
public
UnsignedShort
Type
getImageType
()
public
ARGB
Type
getImageType
()
{
return
type
;
}
@Override
public
Volatile
UnsignedShort
Type
getVolatileImageType
()
public
Volatile
ARGB
Type
getVolatileImageType
()
{
return
volatileType
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/bdv/img/catmaid/CatmaidVolatileIntArrayLoader.java
0 → 100644
+
99
−
0
View file @
928e1424
package
bdv.img.catmaid
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.PixelGrabber
;
import
java.io.IOException
;
import
java.net.URL
;
import
javax.imageio.ImageIO
;
import
net.imglib2.img.basictypeaccess.volatiles.array.VolatileIntArray
;
import
bdv.img.cache.CacheArrayLoader
;
public
class
CatmaidVolatileIntArrayLoader
implements
CacheArrayLoader
<
VolatileIntArray
>
{
private
VolatileIntArray
theEmptyArray
;
private
final
String
baseUrl
;
private
final
int
tileWidth
;
private
final
int
tileHeight
;
public
CatmaidVolatileIntArrayLoader
(
final
String
baseUrl
,
final
int
tileWidth
,
final
int
tileHeight
)
{
theEmptyArray
=
new
VolatileIntArray
(
256
*
256
,
false
);
this
.
baseUrl
=
baseUrl
;
this
.
tileWidth
=
tileWidth
;
this
.
tileHeight
=
tileHeight
;
}
@Override
public
int
getBytesPerElement
()
{
return
1
;
}
@Override
public
VolatileIntArray
loadArray
(
final
int
timepoint
,
final
int
setup
,
final
int
level
,
final
int
[]
dimensions
,
final
long
[]
min
)
throws
InterruptedException
{
final
int
c
=
(
int
)
min
[
0
]
/
tileWidth
;
final
int
r
=
(
int
)
min
[
1
]
/
tileHeight
;
final
int
z
=
(
int
)
min
[
2
];
final
int
s
=
level
;
final
String
urlString
=
new
StringBuffer
(
baseUrl
).
append
(
z
).
append
(
"/"
).
append
(
r
).
append
(
"_"
).
append
(
c
).
append
(
"_"
).
append
(
s
).
append
(
".jpg"
).
toString
();
final
int
w
=
dimensions
[
0
];
final
int
h
=
dimensions
[
1
];
final
int
[]
data
=
new
int
[
w
*
h
];
try
{
final
URL
url
=
new
URL
(
urlString
);
// final Image image = toolkit.createImage( url );
final
BufferedImage
jpg
=
ImageIO
.
read
(
url
);
/* This gymnastic is necessary to get reproducible gray
* values, just opening a JPG or PNG, even when saved by
* ImageIO, and grabbing its pixels results in gray values
* with a non-matching gamma transfer function, I cannot tell
* why... */
final
BufferedImage
image
=
new
BufferedImage
(
w
,
h
,
BufferedImage
.
TYPE_INT_RGB
);
image
.
createGraphics
().
drawImage
(
jpg
,
0
,
0
,
null
);
final
PixelGrabber
pg
=
new
PixelGrabber
(
image
,
0
,
0
,
w
,
h
,
data
,
0
,
w
);
pg
.
grabPixels
();
// System.out.println( "success loading r=" + entry.key.r + " c=" + entry.key.c + " url(" + urlString + ")" );
}
catch
(
final
IOException
e
)
{
System
.
out
.
println
(
"failed loading r="
+
r
+
" c="
+
c
+
" url("
+
urlString
+
")"
);
}
catch
(
final
InterruptedException
e
)
{
e
.
printStackTrace
();
}
return
new
VolatileIntArray
(
data
,
true
);
}
@Override
public
VolatileIntArray
emptyArray
(
final
int
[]
dimensions
)
{
int
numEntities
=
1
;
for
(
int
i
=
0
;
i
<
dimensions
.
length
;
++
i
)
numEntities
*=
dimensions
[
i
];
if
(
theEmptyArray
.
getCurrentStorageArray
().
length
<
numEntities
)
theEmptyArray
=
new
VolatileIntArray
(
numEntities
,
false
);
return
theEmptyArray
;
}
}
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