Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Convexify
Manage
Activity
Members
Labels
Plan
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
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
Bioimage Analysis
Icy
Extensions
Convexify
Commits
2e991fb9
Commit
2e991fb9
authored
4 years ago
by
Amandine TOURNAY
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
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
+8
-0
8 additions, 0 deletions
.gitignore
pom.xml
+92
-0
92 additions, 0 deletions
pom.xml
src/main/java/plugins/adufour/roi/Convexify.java
+175
-0
175 additions, 0 deletions
src/main/java/plugins/adufour/roi/Convexify.java
with
275 additions
and
0 deletions
.gitignore
0 → 100644
+
8
−
0
View file @
2e991fb9
.idea/
.settings/
build/
target/
*.iml
.classpath
.project
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pom.xml
0 → 100644
+
92
−
0
View file @
2e991fb9
<?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"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
icy-convexify
</artifactId>
<version>
2.0.4
</version>
<packaging>
jar
</packaging>
<name>
Convexify
</name>
<description>
Creates convex versions of regions of interests in 2D or 3D using the QuickHull library.
</description>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<jdk.version>
1.8
</jdk.version>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<outputJar>
${project.build.outputDirectory}/../plugin
</outputJar>
</properties>
<build>
<finalName>
${project.artifactId}
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<version>
3.1.2
</version>
<configuration>
<outputDirectory>
${outputJar}
</outputDirectory>
<archive>
<manifest>
<addClasspath>
true
</addClasspath>
<mainClass>
plugins.adufour.roi.Convexify
</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
icy-kernel
</artifactId>
<version>
2.1.0
</version>
</dependency>
<dependency>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
icy-protocols
</artifactId>
<version>
3.0.9
</version>
</dependency>
<dependency>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
icy-quickhull
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
org.bioimageanalysis.icy
</groupId>
<artifactId>
icy-3d-mesh-roi
</artifactId>
<version>
1.4.7
</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>
icy
</id>
<url>
https://icy-nexus.pasteur.fr/repository/Icy/
</url>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>
icy-dev
</id>
<name>
icy-dev
</name>
<url>
https://icy-nexus-dev.pasteur.cloud/repository/icy-core/
</url>
</snapshotRepository>
<repository>
<id>
icy-prod
</id>
<name>
icy-prod
</name>
<url>
https://icy-nexus.pasteur.fr/repository/icy-core/
</url>
</repository>
</distributionManagement>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/plugins/adufour/roi/Convexify.java
0 → 100644
+
175
−
0
View file @
2e991fb9
package
plugins.adufour.roi
;
import
icy.roi.ROI
;
import
icy.roi.ROI2D
;
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
;
import
plugins.adufour.ezplug.EzVarBoolean
;
import
plugins.adufour.ezplug.EzVarSequence
;
import
plugins.adufour.quickhull.QuickHull2D
;
import
plugins.adufour.quickhull.QuickHull3D
;
import
plugins.adufour.roi.mesh.polygon.ROI3DPolygonalMesh
;
import
plugins.adufour.vars.lang.VarROIArray
;
import
plugins.kernel.roi.roi2d.ROI2DArea
;
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"
);
private
EzVarBoolean
replace
=
new
EzVarBoolean
(
"Replace existing ROI"
,
false
);
private
VarROIArray
roiIN
=
new
VarROIArray
(
"List of ROI"
);
private
VarROIArray
roiOUT
=
new
VarROIArray
(
"List of ROI"
);
@Override
protected
void
initialize
()
{
addEzComponent
(
input
);
addEzComponent
(
replace
);
}
@Override
public
void
clean
()
{
}
@Override
public
void
execute
()
{
if
(!
isHeadLess
())
{
roiIN
.
setValue
(
new
ROI
[
0
]);
Sequence
s
=
input
.
getValue
(
true
);
roiIN
.
add
(
s
.
getROIs
().
toArray
(
new
ROI
[
0
]));
}
roiOUT
.
setValue
(
new
ROI
[
0
]);
for
(
ROI
roi
:
roiIN
)
roiOUT
.
add
(
createConvexROI
(
roi
));
if
(!
isHeadLess
())
{
Sequence
s
=
input
.
getValue
(
true
);
if
(
replace
.
getValue
())
s
.
removeAllROI
();
for
(
ROI
roi
:
roiOUT
)
{
s
.
addROI
(
roi
);
}
}
}
/**
* Creates a convex ROI from the specified ROI.
*
* @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
*/
public
static
ROI
createConvexROI
(
ROI
roi
)
throws
IllegalArgumentException
{
ROI
output
=
null
;
try
{
if
(
roi
instanceof
ROI2D
)
{
final
List
<
Point2D
>
envelope
;
if
(
roi
instanceof
ROI2DShape
)
{
envelope
=
QuickHull2D
.
computeConvexEnvelope
(((
ROI2DShape
)
roi
).
getPoints
());
}
else
if
(
roi
instanceof
ROI2DArea
)
{
Point2D
[]
points
=
((
ROI2DArea
)
roi
).
getBooleanMask
(
true
).
getContourPoints
();
envelope
=
QuickHull2D
.
computeConvexEnvelope
(
Arrays
.
asList
(
points
));
}
else
{
throw
new
IllegalArgumentException
(
"Cannot compute convex hull for ROI "
+
roi
.
getName
()
+
" of type "
+
roi
.
getClassName
()
+
"."
);
}
output
=
new
ROI2DPolygon
(
envelope
);
// copy position info
final
ROI2D
roi2d
=
(
ROI2D
)
roi
;
((
ROI2D
)
output
).
setT
(
roi2d
.
getT
());
((
ROI2D
)
output
).
setZ
(
roi2d
.
getZ
());
((
ROI2D
)
output
).
setC
(
roi2d
.
getC
());
}
else
if
(
roi
instanceof
ROI3D
)
{
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
];
pt3d
[
i
]
=
new
Point3d
(
p
.
getX
(),
p
.
getY
(),
p
.
getZ
());
}
QuickHull3D
qhull
=
new
QuickHull3D
();
qhull
.
build
(
pt3d
,
pt3d
.
length
);
// Use a 3D mesh to prepare the final ROI
output
=
new
ROI3DPolygonalMesh
(
qhull
);
// copy position info
final
ROI3D
roi2d
=
(
ROI3D
)
roi
;
((
ROI3D
)
output
).
setT
(
roi2d
.
getT
());
((
ROI2D
)
output
).
setC
(
roi2d
.
getC
());
}
}
catch
(
Throwable
t
)
{
// can happen with QuickHull3D / ROI3DPolygonalMesh...
}
if
(
output
==
null
)
throw
new
IllegalArgumentException
(
"Cannot compute convex hull for ROI "
+
roi
.
getName
()
+
" of type "
+
roi
.
getClassName
()
+
"."
);
ROIUtil
.
copyROIProperties
(
roi
,
output
,
false
);
output
.
setName
(
roi
.
getName
()
+
" (convex)"
);
return
output
;
}
@Override
public
void
declareInput
(
VarList
inputMap
)
{
inputMap
.
add
(
"Regions of interest"
,
roiIN
);
}
@Override
public
void
declareOutput
(
VarList
outputMap
)
{
outputMap
.
add
(
"Regions of interest"
,
roiOUT
);
}
}
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