Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Convexify
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
Package Registry
Container Registry
Operate
Environments
Terraform modules
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
Convexify
Commits
2e0d7476
Commit
2e0d7476
authored
1 year ago
by
Thomas MUSSET
Browse files
Options
Downloads
Patches
Plain Diff
updated pom, optimized code for java 11
parent
2faaa888
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
pom.xml
+5
-7
5 additions, 7 deletions
pom.xml
src/main/java/plugins/adufour/roi/Convexify.java
+60
-64
60 additions, 64 deletions
src/main/java/plugins/adufour/roi/Convexify.java
with
67 additions
and
72 deletions
.gitignore
+
2
−
1
View file @
2e0d7476
...
...
@@ -7,4 +7,5 @@ bin/
*.jar
.classpath
.project
export.jardesc
\ No newline at end of file
export.jardesc
**/.DS_Store
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pom.xml
+
5
−
7
View file @
2e0d7476
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
p
arent-pom-plugin
</artifactId>
<version>
1.0.8
</version>
<artifactId>
p
om-icy
</artifactId>
<version>
2.2.0
</version>
</parent>
<artifactId>
convexify
</artifactId>
<version>
2
.0.
7
</version>
<version>
3
.0.
0
</version>
<packaging>
jar
</packaging>
...
...
@@ -28,12 +28,10 @@
<dependency>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
quickhull
</artifactId>
<version>
${quickhull.version}
</version>
</dependency>
<dependency>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
3d-mesh-roi
</artifactId>
<version>
${three-d-mesh-roi.version}
</version>
</dependency>
</dependencies>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/plugins/adufour/roi/Convexify.java
+
60
−
64
View file @
2e0d7476
/*
* Copyright (c) 2010-2023. Institut Pasteur.
*
* This file is part of Icy.
* Icy is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Icy is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Icy. If not, see <https://www.gnu.org/licenses/>.
*/
package
plugins.adufour.roi
;
import
icy.roi.ROI
;
...
...
@@ -6,13 +24,6 @@ import icy.roi.ROI3D;
import
icy.roi.ROIUtil
;
import
icy.sequence.Sequence
;
import
icy.type.point.Point3D
;
import
java.awt.geom.Point2D
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.vecmath.Point3d
;
import
plugins.adufour.blocks.tools.roi.ROIBlock
;
import
plugins.adufour.blocks.util.VarList
;
import
plugins.adufour.ezplug.EzPlug
;
...
...
@@ -27,52 +38,50 @@ import plugins.kernel.roi.roi2d.ROI2DPolygon;
import
plugins.kernel.roi.roi2d.ROI2DShape
;
import
plugins.kernel.roi.roi3d.ROI3DArea
;
public
class
Convexify
extends
EzPlug
implements
ROIBlock
{
private
EzVarSequence
input
=
new
EzVarSequence
(
"Input sequence"
);
import
javax.vecmath.Point3d
;
import
java.awt.geom.Point2D
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
Convexify
extends
EzPlug
implements
ROIBlock
{
private
final
EzVarSequence
input
=
new
EzVarSequence
(
"Input sequence"
);
private
EzVarBoolean
replace
=
new
EzVarBoolean
(
"Replace existing ROI"
,
false
);
private
final
EzVarBoolean
replace
=
new
EzVarBoolean
(
"Replace existing ROI"
,
false
);
private
VarROIArray
roiIN
=
new
VarROIArray
(
"List of ROI"
);
private
final
VarROIArray
roiIN
=
new
VarROIArray
(
"List of ROI"
);
private
VarROIArray
roiOUT
=
new
VarROIArray
(
"List of ROI"
);
private
final
VarROIArray
roiOUT
=
new
VarROIArray
(
"List of ROI"
);
@Override
protected
void
initialize
()
{
protected
void
initialize
()
{
addEzComponent
(
input
);
addEzComponent
(
replace
);
}
@Override
public
void
clean
()
{
public
void
clean
()
{
}
@Override
public
void
execute
()
{
if
(!
isHeadLess
())
{
public
void
execute
()
{
if
(!
isHeadLess
())
{
roiIN
.
setValue
(
new
ROI
[
0
]);
Sequence
s
=
input
.
getValue
(
true
);
final
Sequence
s
=
input
.
getValue
(
true
);
roiIN
.
add
(
s
.
getROIs
().
toArray
(
new
ROI
[
0
]));
}
roiOUT
.
setValue
(
new
ROI
[
0
]);
for
(
ROI
roi
:
roiIN
)
for
(
final
ROI
roi
:
roiIN
)
roiOUT
.
add
(
createConvexROI
(
roi
));
if
(!
isHeadLess
())
{
Sequence
s
=
input
.
getValue
(
true
);
if
(!
isHeadLess
())
{
final
Sequence
s
=
input
.
getValue
(
true
);
if
(
replace
.
getValue
())
s
.
removeAllROI
();
for
(
ROI
roi
:
roiOUT
)
{
for
(
final
ROI
roi
:
roiOUT
)
{
s
.
addROI
(
roi
);
}
}
...
...
@@ -80,36 +89,28 @@ public class Convexify extends EzPlug implements ROIBlock
/**
* Creates a convex ROI from the specified ROI.
*
* @param roi
* the ROI to be converted into a convex version
*
* @param roi the ROI to be converted into a convex version
* @return a convex version of the ROI. This ROI is currently of type {@link ROI2DPolygon} in
* 2D, and of type {@link ROI3DArea} in 3D, although the return types may change in the
* future.
* @throws IllegalArgumentException
* if the specified ROI is not supported
* 2D, and of type {@link ROI3DArea} in 3D, although the return types may change in the
* future.
* @throws IllegalArgumentException if the specified ROI is not supported
*/
public
static
ROI
createConvexROI
(
ROI
roi
)
throws
IllegalArgumentException
{
public
static
ROI
createConvexROI
(
final
ROI
roi
)
throws
IllegalArgumentException
{
ROI
output
=
null
;
try
{
if
(
roi
instanceof
ROI2D
)
{
try
{
if
(
roi
instanceof
ROI2D
)
{
final
List
<
Point2D
>
envelope
;
if
(
roi
instanceof
ROI2DShape
)
{
if
(
roi
instanceof
ROI2DShape
)
{
envelope
=
QuickHull2D
.
computeConvexEnvelope
(((
ROI2DShape
)
roi
).
getPoints
());
}
else
if
(
roi
instanceof
ROI2DArea
)
{
Point2D
[]
points
=
((
ROI2DArea
)
roi
).
getBooleanMask
(
true
).
getContourPoints
();
else
if
(
roi
instanceof
ROI2DArea
)
{
final
Point2D
[]
points
=
((
ROI2DArea
)
roi
).
getBooleanMask
(
true
).
getContourPoints
();
envelope
=
QuickHull2D
.
computeConvexEnvelope
(
Arrays
.
asList
(
points
));
}
else
{
else
{
throw
new
IllegalArgumentException
(
"Cannot compute convex hull for ROI "
+
roi
.
getName
()
+
" of type "
+
roi
.
getClassName
()
+
"."
);
}
...
...
@@ -122,19 +123,17 @@ public class Convexify extends EzPlug implements ROIBlock
((
ROI2D
)
output
).
setZ
(
roi2d
.
getZ
());
((
ROI2D
)
output
).
setC
(
roi2d
.
getC
());
}
else
if
(
roi
instanceof
ROI3D
)
{
Point3D
[]
points
=
((
ROI3D
)
roi
).
getBooleanMask
(
true
).
getContourPoints
();
else
if
(
roi
instanceof
ROI3D
)
{
final
Point3D
[]
points
=
((
ROI3D
)
roi
).
getBooleanMask
(
true
).
getContourPoints
();
// convert to vecmath's Point3d
Point3d
[]
pt3d
=
new
Point3d
[
points
.
length
];
for
(
int
i
=
0
;
i
<
points
.
length
;
i
++)
{
Point3D
p
=
points
[
i
];
final
Point3d
[]
pt3d
=
new
Point3d
[
points
.
length
];
for
(
int
i
=
0
;
i
<
points
.
length
;
i
++)
{
final
Point3D
p
=
points
[
i
];
pt3d
[
i
]
=
new
Point3d
(
p
.
getX
(),
p
.
getY
(),
p
.
getZ
());
}
QuickHull3D
qhull
=
new
QuickHull3D
();
final
QuickHull3D
qhull
=
new
QuickHull3D
();
qhull
.
build
(
pt3d
,
pt3d
.
length
);
// Use a 3D mesh to prepare the final ROI
...
...
@@ -142,12 +141,11 @@ public class Convexify extends EzPlug implements ROIBlock
// copy position info
final
ROI3D
roi3d
=
(
ROI3D
)
roi
;
((
ROI3D
)
output
).
setT
(
roi3d
.
getT
());
((
ROI3D
)
output
).
setC
(
roi3d
.
getC
());
((
ROI3D
)
output
).
setT
(
roi3d
.
getT
());
((
ROI3D
)
output
).
setC
(
roi3d
.
getC
());
}
}
catch
(
Throwable
t
)
{
catch
(
final
Throwable
t
)
{
// can happen with QuickHull3D / ROI3DPolygonalMesh...
throw
new
IllegalArgumentException
(
"Cannot compute convex hull for ROI "
+
roi
.
getName
()
+
" of type "
+
roi
.
getClassName
()
+
"."
,
t
);
...
...
@@ -164,14 +162,12 @@ public class Convexify extends EzPlug implements ROIBlock
}
@Override
public
void
declareInput
(
VarList
inputMap
)
{
public
void
declareInput
(
final
VarList
inputMap
)
{
inputMap
.
add
(
"Regions of interest"
,
roiIN
);
}
@Override
public
void
declareOutput
(
VarList
outputMap
)
{
public
void
declareOutput
(
final
VarList
outputMap
)
{
outputMap
.
add
(
"Regions of interest"
,
roiOUT
);
}
}
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