Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SLIC - SuperPixels
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bioimage Analysis
SLIC - SuperPixels
Commits
0c39bd3d
Commit
0c39bd3d
authored
6 years ago
by
Daniel Felipe González Obando
Browse files
Options
Downloads
Patches
Plain Diff
using Point and Point3D instead of vecmath
parent
cecf0b07
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SLIC/build.gradle
+0
-1
0 additions, 1 deletion
SLIC/build.gradle
SLIC/src/algorithms/danyfel80/islic/SLICTask.java
+31
-32
31 additions, 32 deletions
SLIC/src/algorithms/danyfel80/islic/SLICTask.java
SLIC/src/plugins/danyfel80/islic/SLIC.java
+0
-9
0 additions, 9 deletions
SLIC/src/plugins/danyfel80/islic/SLIC.java
with
31 additions
and
42 deletions
SLIC/build.gradle
+
0
−
1
View file @
0c39bd3d
...
...
@@ -11,7 +11,6 @@ repositories {
dependencies
{
compile
'org.slf4j:slf4j-api:1.7.21'
compile
'javax.vecmath:vecmath:1.5.2'
compile
files
(
"${System.env.ICY_HOME}/icy.jar"
)
// Icy core
compile
files
(
"${System.env.ICY_HOME}/lib/bioformats.jar"
)
// bioformats
...
...
This diff is collapsed.
Click to expand it.
SLIC/src/algorithms/danyfel80/islic/SLICTask.java
+
31
−
32
View file @
0c39bd3d
...
...
@@ -19,6 +19,7 @@
package
algorithms.danyfel80.islic
;
import
java.awt.Color
;
import
java.awt.Point
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Deque
;
...
...
@@ -31,17 +32,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
javax.vecmath.Point2i
;
import
javax.vecmath.Point3d
;
import
javax.vecmath.Point3i
;
import
javax.vecmath.Vector3d
;
import
icy.image.IcyBufferedImage
;
import
icy.roi.BooleanMask2D
;
import
icy.roi.ROI
;
import
icy.sequence.Sequence
;
import
icy.type.DataType
;
import
icy.type.collection.array.Array2DUtil
;
import
icy.type.point.Point3D
;
import
plugins.kernel.roi.roi2d.ROI2DArea
;
/**
...
...
@@ -64,8 +61,8 @@ public class SLICTask {
private
List
<
ROI
>
rois
;
private
Sequence
superPixelsResult
;
private
Map
<
Point3
i
,
double
[]>
colorLUT
;
private
Map
<
Point
2i
,
Double
>
distanceLUT
;
private
Map
<
Point3
D
.
Integer
,
double
[]>
colorLUT
;
private
Map
<
Point
,
Double
>
distanceLUT
;
public
SLICTask
(
Sequence
sequence
,
int
SPSize
,
double
rigidity
,
boolean
computeROIs
)
{
this
.
sequence
=
sequence
;
...
...
@@ -163,8 +160,8 @@ public class SLICTask {
int
[]
valRGB2
=
new
int
[
3
];
IntStream
.
range
(
0
,
3
).
forEach
(
c
->
{
try
{
valRGB1
[
c
]
=
(
int
)
Math
.
round
(
255
*
(
data
[
c
%
sequence
.
getSizeC
()][
pos1
]
/
sequence
.
getDataTypeMax
()));
valRGB2
[
c
]
=
(
int
)
Math
.
round
(
255
*
(
data
[
c
%
sequence
.
getSizeC
()][
pos2
]
/
sequence
.
getDataTypeMax
()));
valRGB1
[
c
]
=
(
int
)
Math
.
round
(
255
*
(
data
[
c
%
sequence
.
getSizeC
()][
pos1
]
/
sequence
.
getDataTypeMax
()));
valRGB2
[
c
]
=
(
int
)
Math
.
round
(
255
*
(
data
[
c
%
sequence
.
getSizeC
()][
pos2
]
/
sequence
.
getDataTypeMax
()));
}
catch
(
Exception
e
)
{
throw
e
;
}
...
...
@@ -179,12 +176,12 @@ public class SLICTask {
}
private
double
[]
getCIELab
(
double
[][]
sequenceData
,
int
pos
)
{
Point3i
rgbPoint
=
new
Point3i
();
int
[]
rgbVal
=
new
int
[
3
];
IntStream
.
range
(
0
,
3
).
forEach
(
c
->
{
rgbVal
[
c
]
=
(
int
)
Math
.
round
(
255
*
(
sequenceData
[
c
%
sequence
.
getSizeC
()][
pos
]
/
sequence
.
getDataTypeMax
()));
});
rgbPoint
.
set
(
rgbVal
);
Point3D
.
Integer
rgbPoint
=
new
Point3D
.
Integer
(
rgbVal
);
double
[]
LAB
=
colorLUT
.
get
(
rgbPoint
);
if
(
LAB
==
null
)
{
...
...
@@ -244,7 +241,7 @@ public class SLICTask {
diffb
=
bi
-
bk
;
double
dc
=
Math
.
sqrt
(
diffl
*
diffl
+
diffa
*
diffa
+
diffb
*
diffb
);
Point
2i
dPt
=
new
Point
2i
((
int
)
Math
.
min
(
dx
,
dy
),
(
int
)
Math
.
max
(
dx
,
dy
));
Point
dPt
=
new
Point
((
int
)
Math
.
min
(
dx
,
dy
),
(
int
)
Math
.
max
(
dx
,
dy
));
Double
ds
=
distanceLUT
.
get
(
dPt
);
if
(
ds
==
null
)
{
ds
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
...
...
@@ -313,16 +310,16 @@ public class SLICTask {
boolean
[]
visited
=
new
boolean
[
clusters
.
length
];
int
[]
finalClusters
=
new
int
[
clusters
.
length
];
List
<
Point3
d
>
labs
=
new
ArrayList
<>(
SPnum
);
List
<
Point3
D
.
Double
>
labs
=
new
ArrayList
<>(
SPnum
);
List
<
Double
>
areas
=
new
ArrayList
<>(
SPnum
);
List
<
Point
2i
>
firstPoints
=
new
ArrayList
<>(
SPnum
);
List
<
Point
>
firstPoints
=
new
ArrayList
<>(
SPnum
);
// fill known clusters
AtomicInteger
usedLabels
=
new
AtomicInteger
(
0
);
IntStream
.
range
(
0
,
SPnum
).
forEach
(
i
->
{
Point3
d
labCenter
=
new
Point3
d
();
Point3
D
.
Double
labCenter
=
new
Point3
D
.
Double
();
AtomicInteger
area
=
new
AtomicInteger
(
0
);
Point
2i
p
=
new
Point
2i
((
int
)
Math
.
round
(
cxs
[
i
]),
(
int
)
Math
.
round
(
cys
[
i
]));
Point
p
=
new
Point
((
int
)
Math
.
round
(
cxs
[
i
]),
(
int
)
Math
.
round
(
cys
[
i
]));
int
pPos
=
p
.
x
+
p
.
y
*
sequence
.
getWidth
();
if
(
clusters
[
pPos
]
==
i
&&
!
visited
[
pPos
])
{
...
...
@@ -343,9 +340,9 @@ public class SLICTask {
for
(
int
x
=
0
;
x
<
sequence
.
getWidth
();
x
++)
{
int
pos
=
x
+
yOff
;
if
(!
visited
[
pos
])
{
Point3
d
labCenter
=
new
Point3
d
();
Point3
D
.
Double
labCenter
=
new
Point3
D
.
Double
();
AtomicInteger
area
=
new
AtomicInteger
(
0
);
Point
2i
p
=
new
Point
2i
(
x
,
y
);
Point
p
=
new
Point
(
x
,
y
);
findAreaAndColor
(
sequenceData
,
clusters
,
finalClusters
,
visited
,
p
,
labCenter
,
area
,
usedLabels
.
getAndIncrement
());
...
...
@@ -408,7 +405,7 @@ public class SLICTask {
while
(
appliedLabel
!=
mergedRefs
[
appliedLabel
])
{
appliedLabel
=
mergedRefs
[
appliedLabel
];
}
findAreaAndColor
(
sequenceData
,
clusters
,
finalClusters
,
visited
,
firstPoints
.
get
(
i
),
new
Point3
d
(),
findAreaAndColor
(
sequenceData
,
clusters
,
finalClusters
,
visited
,
firstPoints
.
get
(
i
),
new
Point3
D
.
Double
(),
new
AtomicInteger
(
0
),
appliedLabel
);
}
...
...
@@ -450,20 +447,22 @@ public class SLICTask {
}
}
private
void
findAreaAndColor
(
double
[][]
sequenceData
,
int
[]
clusters
,
int
[]
newClusters
,
boolean
[]
visited
,
Point
2i
p
,
Point3d
labCenter
,
AtomicInteger
area
,
int
label
)
{
private
void
findAreaAndColor
(
double
[][]
sequenceData
,
int
[]
clusters
,
int
[]
newClusters
,
boolean
[]
visited
,
Point
p
,
Point
3D
.
Double
labCenter
,
AtomicInteger
area
,
int
label
)
{
int
posp
=
p
.
x
+
p
.
y
*
sequence
.
getWidth
();
area
.
set
(
0
);
labCenter
.
set
(
0
,
0
,
0
);
labCenter
.
x
=
0
d
;
labCenter
.
y
=
0
d
;
labCenter
.
z
=
0
d
;
Deque
<
Point
2i
>
q
=
new
LinkedList
<>();
Deque
<
Point
>
q
=
new
LinkedList
<>();
int
val
=
clusters
[
posp
];
visited
[
posp
]
=
true
;
q
.
add
(
p
);
while
(!
q
.
isEmpty
())
{
Point
2i
pti
=
q
.
pop
();
Point
pti
=
q
.
pop
();
int
posi
=
pti
.
x
+
pti
.
y
*
sequence
.
getWidth
();
newClusters
[
posi
]
=
label
;
...
...
@@ -475,7 +474,7 @@ public class SLICTask {
int
[]
ds
=
new
int
[]
{
0
,
-
1
,
0
,
1
,
0
};
for
(
int
is
=
1
;
is
<
ds
.
length
;
is
++)
{
Point
2i
ptn
=
new
Point
2i
(
pti
.
x
+
ds
[
is
-
1
],
pti
.
y
+
ds
[
is
]);
Point
ptn
=
new
Point
(
pti
.
x
+
ds
[
is
-
1
],
pti
.
y
+
ds
[
is
]);
int
posn
=
ptn
.
x
+
ptn
.
y
*
sequence
.
getWidth
();
if
(
sequence
.
getBounds2D
().
contains
(
ptn
.
x
,
ptn
.
y
)
&&
!
visited
[
posn
]
&&
clusters
[
posn
]
==
val
)
{
visited
[
posn
]
=
true
;
...
...
@@ -486,23 +485,23 @@ public class SLICTask {
}
}
private
List
<
Integer
>
findNeighbors
(
int
[]
newClusters
,
boolean
[]
visited
,
Point
2i
p
)
{
private
List
<
Integer
>
findNeighbors
(
int
[]
newClusters
,
boolean
[]
visited
,
Point
p
)
{
int
posp
=
p
.
x
+
p
.
y
*
sequence
.
getWidth
();
HashSet
<
Integer
>
neighs
=
new
HashSet
<>();
Deque
<
Point
2i
>
q
=
new
LinkedList
<>();
Deque
<
Point
>
q
=
new
LinkedList
<>();
int
val
=
newClusters
[
posp
];
visited
[
posp
]
=
false
;
q
.
add
(
p
);
while
(!
q
.
isEmpty
())
{
Point
2i
pti
=
q
.
pop
();
Point
pti
=
q
.
pop
();
int
[]
ds
=
new
int
[]
{
0
,
-
1
,
0
,
1
,
0
};
for
(
int
is
=
1
;
is
<
ds
.
length
;
is
++)
{
Point
2i
ptn
=
new
Point
2i
(
pti
.
x
+
ds
[
is
-
1
],
pti
.
y
+
ds
[
is
]);
Point
ptn
=
new
Point
(
pti
.
x
+
ds
[
is
-
1
],
pti
.
y
+
ds
[
is
]);
int
posn
=
ptn
.
x
+
ptn
.
y
*
sequence
.
getWidth
();
if
(
sequence
.
getBounds2D
().
contains
(
ptn
.
x
,
ptn
.
y
))
{
if
(
newClusters
[
posn
]
==
val
)
{
...
...
@@ -520,8 +519,8 @@ public class SLICTask {
return
new
ArrayList
<
Integer
>(
neighs
);
}
private
double
computeL
(
List
<
Point3
d
>
labs
,
List
<
Double
>
areas
,
int
i
,
Integer
j
)
{
Vector3d
diffLab
=
new
Vector3d
();
private
double
computeL
(
List
<
Point3
D
.
Double
>
labs
,
List
<
Double
>
areas
,
int
i
,
Integer
j
)
{
Point3D
.
Double
diffLab
=
new
Point3D
.
Double
();
diffLab
.
x
=
labs
.
get
(
j
).
x
-
labs
.
get
(
i
).
x
;
diffLab
.
y
=
labs
.
get
(
j
).
y
-
labs
.
get
(
i
).
y
;
diffLab
.
z
=
labs
.
get
(
j
).
z
-
labs
.
get
(
i
).
z
;
...
...
@@ -533,7 +532,7 @@ public class SLICTask {
}
}
private
ROI2DArea
defineROI
(
int
[]
newClusters
,
Point
2i
p
,
Point3
d
labP
)
{
private
ROI2DArea
defineROI
(
int
[]
newClusters
,
Point
p
,
Point3
D
.
Double
labP
)
{
int
posp
=
p
.
x
+
p
.
y
*
sequence
.
getWidth
();
double
[]
lab
=
new
double
[]
{
labP
.
x
,
labP
.
y
,
labP
.
z
};
int
[]
rgb
=
CIELab
.
toRGB
(
lab
);
...
...
This diff is collapsed.
Click to expand it.
SLIC/src/plugins/danyfel80/islic/SLIC.java
+
0
−
9
View file @
0c39bd3d
...
...
@@ -17,15 +17,6 @@ public class SLIC extends EzPlug {
@Override
protected
void
initialize
()
{
try
{
Class
.
forName
(
"javax.vecmath.Point2i"
);
Class
.
forName
(
"javax.vecmath.Point3d"
);
Class
.
forName
(
"javax.vecmath.Point3i"
);
Class
.
forName
(
"javax.vecmath.Vector3d"
);
}
catch
(
ClassNotFoundException
e
)
{
System
.
err
.
println
(
"Could not load proper vecmath version: "
+
e
);
e
.
printStackTrace
();
}
inSequence
=
new
EzVarSequence
(
"Sequence"
);
inSPSize
=
new
EzVarInteger
(
"Superpixel size"
);
inSPReg
=
new
EzVarDouble
(
"Superpixels regularity"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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