Skip to content

Commit

Permalink
keep integrating
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 27, 2024
1 parent 5b07dc7 commit 97cede4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/ai/nets/samj/gui/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import ai.nets.samj.gui.components.ModelDrawerPanel.ModelDrawerPanelListener;
import ai.nets.samj.ui.ConsumerInterface;
import ai.nets.samj.utils.Constants;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.util.Cast;

import javax.swing.*;
Expand Down Expand Up @@ -97,7 +100,13 @@ public MainGUI(List<SAMModel> modelList, ConsumerInterface consumer) {
chkInstant.addActionListener(e -> setInstantPromptsEnabled(this.chkInstant.isSelected()));
chkRoiManager.addActionListener(e -> consumer.enableAddingToRoiManager(chkRoiManager.isSelected()));
retunLargest.addActionListener(e -> cmbModels.getSelectedModel().setReturnOnlyBiggest(retunLargest.isSelected()));
btnBatchSAMize.addActionListener(e -> consumer.exportImageLabeling());
btnBatchSAMize.addActionListener(e -> {
try {
batchSAMize();
} catch (IOException | RuntimeException | InterruptedException e1) {
e1.printStackTrace();
}
});
close.addActionListener(e -> dispose());
help.addActionListener(e -> consumer.exportImageLabeling());

Expand Down Expand Up @@ -430,6 +439,11 @@ private void toggleDrawer() {
repaint();
}

private < T extends RealType< T > & NativeType< T > > void batchSAMize() throws IOException, RuntimeException, InterruptedException {
RandomAccessibleInterval<T> rai = Cast.unchecked(((ComboBoxItem) cmbPresets.getSelectedItem()).getImageAsImgLib2());
this.consumer.addPolygonsFromGUI(this.cmbModels.getSelectedModel().fetch2dSegmentationFromMask(rai));
}

private void updatePresetsCard() {
CardLayout cl = (CardLayout) (cardPanel.getLayout());
cl.show(cardPanel, PRESET_STR);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/ai/nets/samj/ui/ConsumerInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.awt.Polygon;
import java.util.List;

import ai.nets.samj.annotation.Mask;
import ai.nets.samj.communication.model.SAMModel;
import ai.nets.samj.gui.components.ComboBoxItem;

Expand Down Expand Up @@ -65,6 +66,8 @@ public abstract class ConsumerInterface {
*/
public abstract void exportImageLabeling();

public abstract void addPolygonsFromGUI(List<Mask> masks);

public abstract void activateListeners();

public abstract void deactivateListeners();
Expand Down

0 comments on commit 97cede4

Please sign in to comment.