Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
ba8e33b
feat: create a new jar for opencv 4.5.5
MatteoIorio11 May 13, 2025
dcdefcf
feat: add new opencv 4.5.5 dynamic library for arm (MacOS)
MatteoIorio11 May 13, 2025
f5cf216
refactor: add new line for aarch64, use new library and remove comments
MatteoIorio11 May 13, 2025
b23cfb7
refactor: remove OS check, now SIFT can be used
MatteoIorio11 May 13, 2025
d2eaff5
Merge pull request #3 from MatteoIorio11/dev
UniBoDS4H May 13, 2025
5171ab8
feat(image): override equals and hashCode
MatteoIorio11 May 15, 2025
53bc7b6
feat: add new hashmap for references between Image and its canvas
MatteoIorio11 May 15, 2025
c7bd473
feat: set canvas reference to input image
MatteoIorio11 May 15, 2025
62e374d
refactor: use not isEmpty instead of checking if the size is not zero
MatteoIorio11 May 15, 2025
bac6c4b
fix: use correct check for total used memory. Use new limit for the m…
MatteoIorio11 May 15, 2025
75a5264
feat: init ViewBag class
MatteoIorio11 May 19, 2025
5abd25b
refactor: remove references
MatteoIorio11 May 19, 2025
617886d
feat: set private Contructor
MatteoIorio11 May 19, 2025
532ce27
refactor: use ViewBag reference map instead of MenuItem map
MatteoIorio11 May 19, 2025
980d4e0
feat: remove reference when the image is deleted
MatteoIorio11 May 19, 2025
d169e75
Merge branch 'fix/copy-corner' into fix/memory-controller
MatteoIorio11 May 20, 2025
04b4794
fix: if all the points are removed, it is necessary to clear the image
MatteoIorio11 May 20, 2025
c480d3a
feat: create getter for the overlay
MatteoIorio11 May 20, 2025
efa9213
fix: remove clearing of all the selected points
MatteoIorio11 May 20, 2025
3b75dc9
Merge branch 'fix/copy-corner' into fix/memory-controller
MatteoIorio11 May 20, 2025
d0a5c6a
chore(deps): use shade instead of goal for jar creation
MatteoIorio11 May 20, 2025
3f94355
fix: refresh of remaining points
MatteoIorio11 May 20, 2025
06f26db
Merge branch 'fix/copy-corner' into fix/memory-controller
MatteoIorio11 May 20, 2025
be83843
Merge pull request #4 from MatteoIorio11/fix/copy-corner
UniBoDS4H May 21, 2025
71e1c3e
chore(dep): add BigWarp, N5 dependencies
MatteoIorio11 Jun 6, 2025
6a8500b
refactor: create new package image. Move AlignedImage and ImagePoints…
MatteoIorio11 Jun 6, 2025
1839e93
feat(point): create point repository interface.
MatteoIorio11 Jun 6, 2025
bfef7ac
doc: add javadoc
MatteoIorio11 Jun 6, 2025
3a12075
feat: create new interface DataImage. This interface exposes getGrayS…
MatteoIorio11 Jun 6, 2025
403354f
feat: implement interface PointRepository and DataImage
MatteoIorio11 Jun 6, 2025
1c1ee98
feat: implement DataImage and PointRepository
MatteoIorio11 Jun 6, 2025
f15d135
feat: add @NotNull annotations
MatteoIorio11 Jun 6, 2025
553cf7d
feat: add @NotNull annotations
MatteoIorio11 Jun 6, 2025
354c40b
feat: create new interface AnalyzableImage that extends PointReposito…
MatteoIorio11 Jun 6, 2025
adfc399
feat: implement AnalyzableImage interface
MatteoIorio11 Jun 6, 2025
63ba669
refactor: use AnalyzableImage in detectPoint signature
MatteoIorio11 Jun 6, 2025
b17fa22
feat: add totalPoints api
MatteoIorio11 Jun 6, 2025
7acbd7c
feat: implement totalPoints api
MatteoIorio11 Jun 6, 2025
2b9bd10
refactor: use new apis
MatteoIorio11 Jun 6, 2025
dad0498
refactor(view): use new apis
MatteoIorio11 Jun 6, 2025
0984596
refactor(controller): use new api
MatteoIorio11 Jun 6, 2025
6cf018f
feat: add new interface regarding the elastic registration
MatteoIorio11 Jun 6, 2025
bf3e58a
feat: add NotNull annotation
MatteoIorio11 Jun 6, 2025
91e9e45
feat: implement ElasticRegistration
MatteoIorio11 Jun 6, 2025
3c2efec
refactor(elastic): use CompletableFuture instead of Future
MatteoIorio11 Jun 7, 2025
7843bcd
refactor: use CompletableFuture
MatteoIorio11 Jun 7, 2025
33bff3f
feat: init apply elastic registration
MatteoIorio11 Jun 7, 2025
1e4251b
feat: implement apply elastic registration
MatteoIorio11 Jun 7, 2025
4a21a98
feat: add method for updating the landmark table with image's points
MatteoIorio11 Jun 7, 2025
7f36892
feat: add initializeSources method
MatteoIorio11 Jun 7, 2025
9745282
feat: implement logic for elastic registration
MatteoIorio11 Jun 7, 2025
48ea912
feat: add method for clearing points
MatteoIorio11 Jun 8, 2025
d122026
chore: refactor main algorithm logic, create new method for automatic…
MatteoIorio11 Jun 8, 2025
34e01bd
feat: implement method for aligning multiple images
MatteoIorio11 Jun 8, 2025
caee63a
refactor: remove circular dependency
MatteoIorio11 Jun 9, 2025
838fb3a
feat: add getImage method and getName method
MatteoIorio11 Jun 9, 2025
c0ad975
refactor: getImage -> getImagePlus
MatteoIorio11 Jun 9, 2025
ac73017
feat: implement getName and getImagePlus
MatteoIorio11 Jun 9, 2025
b0e713b
feat: implement getName and getImagePlus
MatteoIorio11 Jun 9, 2025
2045cc3
feat: use AnalyzableImage in the signature
MatteoIorio11 Jun 9, 2025
e8679b6
refactor: use AnalyzableImage
MatteoIorio11 Jun 9, 2025
0c58d5f
feat(view): add new manual elastic alignment and automatic elastic al…
MatteoIorio11 Jun 9, 2025
b79c090
refactor: create constant for ToolTip message. Enable manual elastic …
MatteoIorio11 Jun 9, 2025
400d98a
feat: enable button when there are at least two images
MatteoIorio11 Jun 10, 2025
000968b
feat: check for input points
MatteoIorio11 Jun 10, 2025
612a6cb
refactor: change class name
MatteoIorio11 Jun 10, 2025
3c22d9d
refactor: change constructor signature
MatteoIorio11 Jun 10, 2025
c0ce16c
refactor: change function signature
MatteoIorio11 Jun 10, 2025
0dbf76a
feat: add override
MatteoIorio11 Jun 10, 2025
990b70d
feat: init elastic controller
MatteoIorio11 Jun 10, 2025
4137bfd
feat: init elastic controller
MatteoIorio11 Jun 10, 2025
01b1b7e
feat: add new method for aligning only one image
MatteoIorio11 Jun 10, 2025
481b7e8
feat: override new method
MatteoIorio11 Jun 10, 2025
ba7eada
refactor: rename PointManager to ImageManager
MatteoIorio11 Jun 10, 2025
8dfe469
refactor: use ImageManager instead of PointManager
MatteoIorio11 Jun 10, 2025
c114682
feat: implement automatic registration
MatteoIorio11 Jun 10, 2025
1e303f2
refactor: rename PointController into ImageManagerController
MatteoIorio11 Jun 10, 2025
3c23669
refactor: use new controller
MatteoIorio11 Jun 10, 2025
2533eea
feat: add manual alignment
MatteoIorio11 Jun 10, 2025
3508d60
feat: init image stack creator
MatteoIorio11 Jun 10, 2025
4cc50d7
refactor: rename getImageManager
MatteoIorio11 Jun 10, 2025
78ebfe8
feat: add logic for creating an image stack using a collection of images
MatteoIorio11 Jun 10, 2025
ba2b9fa
feat: use ImageStack creator
MatteoIorio11 Jun 10, 2025
16c07d6
feat: create ElasticOutputImage controller
MatteoIorio11 Jun 10, 2025
c4e9770
refactor: return aligned image
MatteoIorio11 Jun 10, 2025
4688e06
feat: implement core logic for elastic registration
MatteoIorio11 Jun 10, 2025
8bd599d
refactor: return AlignedImage
MatteoIorio11 Jun 11, 2025
b016ecc
refactor: change signature and return only AlignedImages
MatteoIorio11 Jun 11, 2025
8304f23
refactor: use new signature
MatteoIorio11 Jun 11, 2025
fc90bae
fix: set correct order of images
MatteoIorio11 Jun 12, 2025
88ba7bf
feat: implement manual elastic alignment handler
MatteoIorio11 Jun 12, 2025
bb1f313
feat: add logic for automatically add the best match
MatteoIorio11 Jun 12, 2025
416445b
refactor: use new logic for automatically add best matches. Remove du…
MatteoIorio11 Jun 12, 2025
0f62a1b
refactor: use ImageStackCreator
MatteoIorio11 Jun 13, 2025
bd3ac35
refactor: use ImageStackCreator
MatteoIorio11 Jun 13, 2025
c918c4d
feat: remove all points after registration
MatteoIorio11 Jun 13, 2025
a83100c
feat: add logging
MatteoIorio11 Jun 13, 2025
036e5b7
feat: add logging
MatteoIorio11 Jun 13, 2025
d595d4a
feat: set SIFT as default detector
MatteoIorio11 Jun 13, 2025
a9a4066
refactor: use isEmpty instead of checking the size
MatteoIorio11 Jun 13, 2025
33b324a
feat: enable the manual elastic registration when it is possible
MatteoIorio11 Jun 13, 2025
2c70e07
fix: remove all the unnecessary LUTs
MatteoIorio11 Jun 13, 2025
baec532
refactor: move ImageStackCreator inside the model
MatteoIorio11 Jun 13, 2025
be50fa3
doc: add java doc
MatteoIorio11 Jun 14, 2025
78dac54
refactor: change log output
MatteoIorio11 Jun 14, 2025
dcf6a88
feat: init elasticItem, add elasticItem inside the settings menu
MatteoIorio11 Jun 25, 2025
e6b1594
feat: init Automatic elastic config gui
MatteoIorio11 Jun 25, 2025
9eb91c5
feat: extends JFrame and StandardGui
MatteoIorio11 Jun 25, 2025
5db86dc
feat: show settings gui when clicked
MatteoIorio11 Jun 25, 2025
92d71af
feat: add ElasticAlgorithms enum
MatteoIorio11 Jun 25, 2025
7737e6a
feat: add method getAlgorithms. This method allow to return all the d…
MatteoIorio11 Jun 25, 2025
185e201
feat: init combo for algorithms and init controller
MatteoIorio11 Jun 25, 2025
01c617b
feat: add elastic controller inside the automatic elastic config gui
MatteoIorio11 Jun 25, 2025
5ddfcb6
feat: add setAlgorithm method, add currentAlgorithm method
MatteoIorio11 Jun 25, 2025
2de60f4
feat: add Dimension and Title, set correct algorithm after selection.…
MatteoIorio11 Jun 25, 2025
35db957
feat: init Constant class for storing all constants
MatteoIorio11 Jun 26, 2025
58bd259
feat: update Dimension, use constant label
MatteoIorio11 Jun 26, 2025
d2ea83d
refactor: implement ElasticRegistration interface, remove thread logi…
MatteoIorio11 Jun 26, 2025
99f2a6d
refactor: move bunwarpJ controller inside the elastic package
MatteoIorio11 Jun 26, 2025
ba556f4
feat: add elastic registration algorithm inside the constructor
MatteoIorio11 Jun 26, 2025
147f3ad
feat: get and use correct algorithm by selecting the one from the input
MatteoIorio11 Jun 26, 2025
b2d15ac
refactor: bunwarpj controller
MatteoIorio11 Jun 26, 2025
bef2c0d
refactor: use elastic controller instead of bunwarpj controller, enha…
MatteoIorio11 Jun 26, 2025
fafbf94
refactor: use general way for elastic algorithm, avoid polling and in…
MatteoIorio11 Jun 26, 2025
a6adce7
feat: use completable future, use elastic controller
MatteoIorio11 Jun 26, 2025
26b4dd5
feat: add logic and use point detector only if needed
MatteoIorio11 Jun 27, 2025
c6e92e8
refactor: add selected detector inside output gui
MatteoIorio11 Jun 27, 2025
890d729
feat: set selected detector inside constructor
MatteoIorio11 Jun 27, 2025
2cb3e80
feat: use the enum class
MatteoIorio11 Jun 27, 2025
a8661db
feat: override toString, use attribute 'name'
MatteoIorio11 Jun 27, 2025
fa43c19
feat: move about menu to the right, use new name for settings item
MatteoIorio11 Jul 8, 2025
1337d7b
feat: add new constant
MatteoIorio11 Jul 8, 2025
7920f62
feat: add set number of landmarks, in order to better manage the numb…
MatteoIorio11 Jul 15, 2025
3b81534
feat: limit the number of iteration by using the 'max_points' variabl…
MatteoIorio11 Jul 15, 2025
49a3e9a
feat: add text field for number of landmarks
MatteoIorio11 Jul 15, 2025
bb4f68e
feat: add label text
MatteoIorio11 Jul 15, 2025
3849658
refactor: assert canvas not null
MatteoIorio11 Nov 3, 2025
ab5aac9
refactor: rename bUnwarpJ algorithm
MatteoIorio11 Nov 9, 2025
acba9bf
doc: add image documentation
MatteoIorio11 Nov 26, 2025
d35af17
doc: add dcoumentation
MatteoIorio11 Nov 26, 2025
439b274
feat: add @NotNull annotation
MatteoIorio11 Nov 26, 2025
62537cc
feat: add NotNull annotation, remove old code
MatteoIorio11 Nov 26, 2025
3090752
feat: annotate with @NotNull
MatteoIorio11 Nov 26, 2025
4391478
feat: add new annotation @NotNull, mark inheritors also with @NotNull
MatteoIorio11 Nov 26, 2025
d73c2ac
feat: add annotation NotNull to inheritors
MatteoIorio11 Nov 26, 2025
429055c
feat: annotate with NotNull, remove redundant if
MatteoIorio11 Nov 26, 2025
5a2c49d
feat: throw exception when algorithm is not recognised
MatteoIorio11 Nov 26, 2025
92ba322
feat: annotate with notnull, remove calls to gc
MatteoIorio11 Nov 26, 2025
e872ae7
feat: annotate with not null
MatteoIorio11 Nov 26, 2025
76980dd
feat: annotate with NotNull annotation
MatteoIorio11 Nov 26, 2025
ff1fa5b
feat: add not null annotation
MatteoIorio11 Nov 26, 2025
c89cfa4
feat: add not null annotation
MatteoIorio11 Nov 26, 2025
4255d33
feat: add not null annotation
MatteoIorio11 Nov 26, 2025
6cb3bb6
feat: add not null annotation
MatteoIorio11 Nov 26, 2025
2ae9064
feat: add NotNull annotation
MatteoIorio11 Nov 26, 2025
e7af14e
Fix memory usage (#5)
MatteoIorio11 Nov 30, 2025
c1fabb5
Merge branch 'dev' into feat/elastic
MatteoIorio11 Nov 30, 2025
ef0a435
feat: add NotNull annotation
MatteoIorio11 Dec 1, 2025
9fbb9ad
feat: add not null annotation
MatteoIorio11 Dec 1, 2025
5a7ff4c
feat: add not null annotattion
MatteoIorio11 Dec 1, 2025
70a3942
feat: add not null annotation
MatteoIorio11 Dec 1, 2025
52a4b62
feat: add not null annotation
MatteoIorio11 Dec 1, 2025
be483fe
feat: add not null annotation
MatteoIorio11 Dec 1, 2025
589ecf2
feat: add not null annotation
MatteoIorio11 Dec 1, 2025
e8063fa
chore: remove doc
MatteoIorio11 Dec 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 66 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,37 +214,97 @@
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/sc.fiji/bigwarp_fiji -->
<dependency>
<groupId>sc.fiji</groupId>
<artifactId>bigwarp_fiji</artifactId>
<version>9.3.0</version>
</dependency>

<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-blosc</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-ij</artifactId>
<version>4.2.5</version>
<exclusions>
<exclusion>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-imglib2</artifactId>
<version>7.0.2</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-aws-s3</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-google-cloud</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-viewer_fiji</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-zarr</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-universe</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>
<!--

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>com.ds4h.imagej.Image_Alignment</mainClass>
</manifest>
</archive>
<!--
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
-->
</configuration>

<executions>
<execution>
<id>make-assembly</id> this is used for inheritance merges
<phase>package</phase> bind to the packaging phase
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
-->
</project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.ds4h.controller.alignmentController;

import com.ds4h.model.alignedImage.AlignedImage;
import ij.CompositeImage;
import com.drew.lang.annotations.NotNull;
import com.ds4h.model.image.alignedImage.AlignedImage;
import ij.ImagePlus;
import org.bytedeco.opencv.presets.opencv_core;

import java.awt.*;
import java.util.List;

/**
Expand All @@ -16,6 +16,7 @@ public interface AlignmentControllerInterface {
* Returns the aligned images.
* @return the aligned images.
*/
@NotNull
public List<AlignedImage> getAlignedImages();

/**
Expand All @@ -28,12 +29,14 @@ public interface AlignmentControllerInterface {
* Returns the name of the algorithm.
* @return the name of the algorithm.
*/
@NotNull
public String name();

/**
* Returns all the aligned images as stack.
* @return all the aligned images as stack,
*/
@NotNull
public ImagePlus getAlignedImagesAsStack();

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package com.ds4h.controller.alignmentController.AutomaticAlignmentController;

import com.drew.lang.annotations.NotNull;
import com.ds4h.controller.alignmentController.AlignmentControllerInterface;
import com.ds4h.controller.pointController.PointController;
import com.ds4h.model.alignedImage.AlignedImage;
import com.ds4h.controller.pointController.ImageManagerController;
import com.ds4h.model.image.alignedImage.AlignedImage;
import com.ds4h.model.alignment.Alignment;
import com.ds4h.model.alignment.AlignmentEnum;
import com.ds4h.model.alignment.alignmentAlgorithm.*;
import com.ds4h.model.alignment.automatic.pointDetector.Detectors;
import ij.IJ;
import com.ds4h.model.util.ImageStackCreator;
import ij.ImagePlus;
import ij.ImageStack;
import ij.process.ByteProcessor;
import ij.process.ImageConverter;

import java.awt.image.ColorModel;
import java.util.*;
import java.util.stream.Collectors;

/**
* This class is used in order to call all the Model methods of the SURF Alignment inside the view, without
Expand All @@ -42,6 +38,7 @@ public AutomaticAlignmentController(){
* the collection can be empty if the alignment algorithm is not done.
* @return the list with all the images aligned.
*/
@NotNull
@Override
public List<AlignedImage> getAlignedImages() {
return alignment.alignedImages();
Expand All @@ -66,12 +63,14 @@ public void releaseImages(){
* @throws IllegalArgumentException if one of the input is not correct.
* @throws RuntimeException if during the alignment something happen.
*/
public void align(final AlignmentAlgorithm algorithm, final Detectors detector, final PointController pointManager) throws Exception{
public void align(@NotNull final AlignmentAlgorithm algorithm,
@NotNull final Detectors detector,
@NotNull final ImageManagerController pointManager) throws Exception{

if (!this.alignment.isAlive() && Objects.nonNull(pointManager) && Objects.nonNull(pointManager.getPointManager())) {
if (pointManager.getPointManager().getPointImages().size() > 1 && detector.getScaling() >= 1) {
if (!this.alignment.isAlive() && Objects.nonNull(pointManager) && Objects.nonNull(pointManager.getImageManager())) {
if (pointManager.getImageManager().getPointImages().size() > 1 && detector.getScaling() >= 1) {
try{
this.alignment.alignImages(pointManager.getPointManager(), algorithm,
this.alignment.alignImages(pointManager.getImageManager(), algorithm,
AlignmentEnum.AUTOMATIC,
Objects.requireNonNull(detector.pointDetector()),
detector.getThresholdFactor(),
Expand Down Expand Up @@ -100,6 +99,7 @@ public boolean isAlive(){
* Returns the alignment name.
* @return the alignment name.
*/
@NotNull
@Override
public String name() {
return "AUTOMATIC";
Expand All @@ -110,36 +110,11 @@ public String name() {
* @return all the aligned images as stack.
* @throws RuntimeException if something goes wrong (there are no images, etc, etc..).
*/
@NotNull
@Override
public ImagePlus getAlignedImagesAsStack() throws RuntimeException{
if(!this.getAlignedImages().isEmpty()){
final ImageStack stack = new ImageStack(this.getAlignedImages().get(0).getAlignedImage().getWidth(),
this.getAlignedImages().get(0).getAlignedImage().getHeight(), ColorModel.getRGBdefault());
System.gc();
final List<AlignedImage> images = this.getAlignedImages();
//final LUT[] luts = new LUT[images.size()];
//int index = 0;
final int bitDepth = images.stream()
.min(Comparator.comparingInt(img -> img.getAlignedImage().getBitDepth())).get().getAlignedImage().getBitDepth();
IJ.log("[ALIGNED STACK] Bit Depth: " + bitDepth);
for (final AlignedImage image : images) {
if(!(image.getAlignedImage().getProcessor() instanceof ByteProcessor)) {
final ImageConverter imageConverter = new ImageConverter(image.getAlignedImage());
imageConverter.convertToGray8();
IJ.log("[STACK] " + (image.getAlignedImage().getProcessor() instanceof ByteProcessor));
}
//luts[index] = image.getAlignedImage().getProcessor().getLut();
IJ.log("[NAME] " + image.getName());
stack.addSlice(image.getName(), image.getAlignedImage().getProcessor());
//index++;
}
try {
//final CompositeImage composite = new CompositeImage(new ImagePlus("Aligned Stack", stack));
//composite.setLuts(luts);
return new ImagePlus("AlignedStack", stack);
}catch (Exception e){
throw new RuntimeException("Something went wrong with the creation of the stack.");
}
return ImageStackCreator.createImageStack(this.getAlignedImages());
}
throw new RuntimeException("The detection has failed, the number of points found can not be used with the selected \"Algorithm\".\n" +
"Please consider to expand the memory (by going to Edit > Options > Memory & Threads)\n" +
Expand All @@ -159,6 +134,7 @@ public int getStatus() {
* Returns the algorithm.
* @return the algorithm
*/
@NotNull
public AlignmentAlgorithm getAlgorithm() {
return this.algorithm;
}
Expand All @@ -167,18 +143,17 @@ public AlignmentAlgorithm getAlgorithm() {
* Set the algorithm to use.
* @param algorithm the algorithm to use.
*/
public void setAlgorithm(final AlignmentAlgorithm algorithm){
if(Objects.nonNull(algorithm)) {
this.algorithm = algorithm;
}
public void setAlgorithm(@NotNull final AlignmentAlgorithm algorithm){
this.algorithm = algorithm;
}

/**
* Returns the alignment algorithm.
* @param algorithmEnum the selected algorithm.
* @return the alignment algorithm.
*/
public AlignmentAlgorithm getAlgorithmFromEnum(final AlignmentAlgorithmEnum algorithmEnum){
@NotNull
public AlignmentAlgorithm getAlgorithmFromEnum(@NotNull final AlignmentAlgorithmEnum algorithmEnum){
switch (algorithmEnum){
case TRANSLATIONAL:
return this.translational;
Expand All @@ -189,10 +164,8 @@ public AlignmentAlgorithm getAlgorithmFromEnum(final AlignmentAlgorithmEnum algo
}
throw new IllegalArgumentException("Algorithm not present");
}
@NotNull
public Detectors[] getDetectors(){
if(System.getProperty("os.name").toLowerCase().contains("mac")){
return Arrays.stream(Detectors.values()).filter(d -> d != Detectors.SIFT).collect(Collectors.toList()).toArray(new Detectors[0]);
}
return Detectors.values();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.ds4h.controller.alignmentController.ManualAlignmentController;

import com.drew.lang.annotations.NotNull;
import com.ds4h.controller.alignmentController.AlignmentControllerInterface;
import com.ds4h.controller.pointController.PointController;
import com.ds4h.model.alignedImage.AlignedImage;
import com.ds4h.controller.pointController.ImageManagerController;
import com.ds4h.model.image.alignedImage.AlignedImage;
import com.ds4h.model.alignment.Alignment;
import com.ds4h.model.alignment.AlignmentEnum;
import com.ds4h.model.alignment.alignmentAlgorithm.*;
import ij.IJ;
import com.ds4h.model.util.ImageStackCreator;
import ij.ImagePlus;
import ij.ImageStack;
import ij.process.ByteProcessor;
import ij.process.ImageConverter;

import java.awt.image.ColorModel;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
Expand All @@ -39,6 +36,7 @@ public ManualAlignmentController(){
* Returns all the aligned images.
* @return all the aligned images.
*/
@NotNull
@Override
public List<AlignedImage> getAlignedImages(){
return new LinkedList<>(alignment.alignedImages());
Expand All @@ -48,26 +46,10 @@ public List<AlignedImage> getAlignedImages(){
* Returns all the aligned images as stack.
* @return all the aligned images as stack.
*/
@NotNull
public ImagePlus getAlignedImagesAsStack(){
if(!this.getAlignedImages().isEmpty()){
final ImageStack stack = new ImageStack(this.getAlignedImages().get(0).getAlignedImage().getWidth(), this.getAlignedImages().get(0).getAlignedImage().getHeight(), ColorModel.getRGBdefault());
System.gc();
final List<AlignedImage> images = this.getAlignedImages();
//LUT[] luts = new LUT[images.size()];
//int index = 0;
for (final AlignedImage image : images) {
if(!(image.getAlignedImage().getProcessor() instanceof ByteProcessor)) {
final ImageConverter imageConverter = new ImageConverter(image.getAlignedImage());
imageConverter.convertToGray8();
IJ.log("[STACK] " + (image.getAlignedImage().getProcessor() instanceof ByteProcessor));
}
//luts[index] = image.getAlignedImage().getProcessor().getLut();
stack.addSlice(image.getName(),image.getAlignedImage().getProcessor());
//index++;
}
//final CompositeImage composite = new CompositeImage(new ImagePlus("Aligned_Stack", stack));
//composite.setLuts(luts);
return new ImagePlus("AlignedStack", stack);
return ImageStackCreator.createImageStack(this.getAlignedImages());
}
throw new RuntimeException("The detection has failed, the number of points found can not be used with the selected \"Algorithm\".\n" +
"Please consider to expand the memory (by going to Edit > Options > Memory & Threads)\n" +
Expand Down Expand Up @@ -96,6 +78,7 @@ public boolean isAlive() {
* Returns the algorithm name.
* @return the algorithm name.
*/
@NotNull
@Override
public String name() {
return "MANUAL";
Expand All @@ -108,10 +91,10 @@ public String name() {
* @param pointManager where all the images are stored.
* @throws IllegalArgumentException if one of the parameters is not correct.
*/
public void align(final AlignmentAlgorithm algorithm, final PointController pointManager) throws IllegalArgumentException{
if(!this.alignment.isAlive() && Objects.nonNull(pointManager) && Objects.nonNull(pointManager.getPointManager())) {
if(pointManager.getPointManager().getPointImages().size() > 1) {
this.alignment.alignImages(pointManager.getPointManager(), algorithm, AlignmentEnum.MANUAL);
public void align(final AlignmentAlgorithm algorithm, final ImageManagerController pointManager) throws IllegalArgumentException{
if(!this.alignment.isAlive() && Objects.nonNull(pointManager) && Objects.nonNull(pointManager.getImageManager())) {
if(pointManager.getImageManager().getPointImages().size() > 1) {
this.alignment.alignImages(pointManager.getImageManager(), algorithm, AlignmentEnum.MANUAL);
}else{
throw new IllegalArgumentException("For the alignment are needed at least TWO images.");
}
Expand Down Expand Up @@ -176,4 +159,4 @@ public void setPointOverload(final PointOverloadEnum overload) {
public void releaseImages(){
this.alignment.clearList();
}
}
}
Loading