Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Zellige-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
IdA Public
Zellige-core
Commits
c92a89f2
Commit
c92a89f2
authored
1 year ago
by
Céline TREBEAU
Browse files
Options
Downloads
Patches
Plain Diff
- Addition of static methods to get the colors from a specified list of ColorTables
parent
58d126ca
No related branches found
No related tags found
1 merge request
!40
Draft: Resolve "Multi-channel image handling"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/fr/pasteur/ida/zellige/steps/ChannelImageSelection.java
+90
-6
90 additions, 6 deletions
...a/fr/pasteur/ida/zellige/steps/ChannelImageSelection.java
with
90 additions
and
6 deletions
src/main/java/fr/pasteur/ida/zellige/steps/ChannelImageSelection.java
+
90
−
6
View file @
c92a89f2
...
@@ -2,23 +2,39 @@ package fr.pasteur.ida.zellige.steps;
...
@@ -2,23 +2,39 @@ package fr.pasteur.ida.zellige.steps;
import
net.imagej.Dataset
;
import
net.imagej.Dataset
;
import
net.imagej.ImgPlus
;
import
net.imagej.ImgPlus
;
import
net.imagej.display.DefaultDatasetView
;
import
net.imglib2.RandomAccess
;
import
net.imglib2.RandomAccess
;
import
net.imglib2.display.ColorTable
;
import
net.imglib2.img.Img
;
import
net.imglib2.img.Img
;
import
net.imglib2.type.NativeType
;
import
net.imglib2.type.NativeType
;
import
net.imglib2.type.numeric.RealType
;
import
net.imglib2.type.numeric.RealType
;
import
java.util.ArrayList
;
public
class
ChannelImageSelection
<
T
extends
RealType
<
T
>
&
NativeType
<
T
>
>
public
class
ChannelImageSelection
<
T
extends
RealType
<
T
>
&
NativeType
<
T
>
>
{
{
private
final
static
int
GRAYS
=
0
;
private
final
static
int
RED
=
1
;
private
final
static
int
BLUE
=
2
;
private
final
static
int
GREEN
=
3
;
private
final
static
int
CYAN
=
4
;
private
final
static
int
MAGENTA
=
5
;
private
final
static
int
YELLOW
=
6
;
private
final
int
targetChannel
;
private
final
int
targetChannel
;
private
final
Dataset
dataset
;
private
final
Dataset
dataset
;
public
static
<
T
extends
RealType
<
T
>
&
NativeType
<
T
>
>
Img
<
T
>
run
(
Dataset
input
,
int
targetChannel
)
public
static
<
T
extends
RealType
<
T
>
&
NativeType
<
T
>
>
Img
<
T
>
run
(
Dataset
input
,
int
targetChannel
)
{
{
ChannelImageSelection
<
T
>
channelImageSelection
=
new
ChannelImageSelection
<>(
input
,
targetChannel
);
ChannelImageSelection
<
T
>
channelImageSelection
=
new
ChannelImageSelection
<>(
input
,
targetChannel
);
return
channelImageSelection
.
run
();
return
channelImageSelection
.
run
();
}
}
/**
*
* @param dataset
* @param targetChannel
*/
public
ChannelImageSelection
(
Dataset
dataset
,
int
targetChannel
)
public
ChannelImageSelection
(
Dataset
dataset
,
int
targetChannel
)
{
{
this
.
targetChannel
=
targetChannel
;
this
.
targetChannel
=
targetChannel
;
...
@@ -28,9 +44,9 @@ public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
...
@@ -28,9 +44,9 @@ public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
public
Img
<
T
>
run
()
public
Img
<
T
>
run
()
{
{
Img
<
T
>
input
=
(
ImgPlus
<
T
>
)
this
.
dataset
.
getImgPlus
();
Img
<
T
>
input
=
(
ImgPlus
<
T
>
)
this
.
dataset
.
getImgPlus
();
if
(
getTargetChannel
()
==
0
)
if
(
getTargetChannel
()
==
0
)
{
{
return
input
;
return
input
;
}
}
else
else
{
{
...
@@ -43,7 +59,7 @@ public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
...
@@ -43,7 +59,7 @@ public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
{
{
for
(
int
z
=
0
;
z
<
(
int
)
input
.
dimension
(
3
);
z
++
)
for
(
int
z
=
0
;
z
<
(
int
)
input
.
dimension
(
3
);
z
++
)
{
{
randomAccess
.
setPositionAndGet
(
x
,
y
,
getTargetChannel
()
-
1
,
z
);
randomAccess
.
setPositionAndGet
(
x
,
y
,
getTargetChannel
()
-
1
,
z
);
randomAccess1
.
setPosition
(
new
int
[]{
x
,
y
,
z
}
);
randomAccess1
.
setPosition
(
new
int
[]{
x
,
y
,
z
}
);
randomAccess1
.
get
().
set
(
randomAccess
.
get
()
);
randomAccess1
.
get
().
set
(
randomAccess
.
get
()
);
}
}
...
@@ -52,8 +68,76 @@ public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
...
@@ -52,8 +68,76 @@ public class ChannelImageSelection< T extends RealType< T > & NativeType< T > >
return
output
;
return
output
;
}
}
}
}
public
int
getTargetChannel
()
public
int
getTargetChannel
()
{
{
return
targetChannel
;
return
targetChannel
;
}
}
/**
*
* @param defaultDatasetView the input image
* @return an int array of colors
*/
private
static
int
[]
getColors
(
DefaultDatasetView
defaultDatasetView
)
{
return
getColors
(
(
DefaultDatasetView
)
defaultDatasetView
.
getColorTables
()
);
}
private
static
int
[]
getColors
(
ArrayList
<
ColorTable
>
colorTables
)
{
int
[]
colors
=
new
int
[
colorTables
.
size
()
];
if
(
colors
.
length
==
1
)
{
colors
[
0
]
=
GRAYS
;
return
colors
;
}
for
(
int
i
=
0
;
i
<
colorTables
.
size
();
i
++
)
{
colors
[
i
]=
getColor
(
colorTables
.
get
(
i
));
}
return
colors
;
}
private
static
int
getColor
(
ColorTable
colorTable
)
{
int
R
=
colorTable
.
get
(
0
,
255
);
int
G
=
colorTable
.
get
(
1
,
255
);
int
B
=
colorTable
.
get
(
2
,
255
);
if
(
R
==
0
)
{
if
(
G
==
0
)
{
return
BLUE
;
// BLUE
}
else
{
if
(
B
==
0
)
{
return
GREEN
;
// GREEN
}
return
CYAN
;
// CYAN
}
}
else
{
if
(
G
==
0
)
{
if
(
B
==
0
)
{
return
RED
;
// RED
}
return
MAGENTA
;
// MAGENTA
}
else
{
if
(
B
==
0
)
{
return
YELLOW
;
// YELLOW
}
return
GRAYS
;
// GRAYS
}
}
}
}
}
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