Пример #1
0
  public void generateTestSet() {

    List<ImageDisplay> displays = imageDisplayService.getImageDisplays();
    imgDatasets = new ArrayList<>(displays.size());
    List<Dataset> labeledDs = new ArrayList<>(displays.size());
    List<List<Overlay>> overlaySet = new ArrayList<>();

    displays
        .stream()
        .forEach(
            id -> {
              imgDatasets.add(imageDisplayService.getActiveDataset(id));
              overlaySet.add(overlayService.getOverlays(id));
            });

    List<List<Point2D>> seeds = seeding();
    int numProfiles = 0;
    for (int ds = 0; ds < imgDatasets.size(); ds++) {

      List<Point2D> centers = seeds.get(ds);

      ProfilesSet profiles = new DefaultProfilesSet(centers, searchRadius.getValue(), context);
      numProfiles += profiles.size();
      testData.add(profiles);
    }
    eventService.publish(new ProfileEvent(ProfileType.TEST, numProfiles));
  }
Пример #2
0
 /**
  * Updates the menu structure to reflect changes in the given module. Does nothing unless the
  * module is already in the menu structure.
  *
  * @return true if the module was successfully updated
  */
 public boolean update(final ModuleInfo module) {
   final ShadowMenu removed = removeInternal(module);
   if (removed == null) return false; // was not in menu structure
   final ShadowMenu node = addInternal(module);
   if (node == null) return false;
   if (es != null) es.publish(new MenusUpdatedEvent(node));
   return true;
 }
Пример #3
0
  @Override
  public void setActiveTool(final Tool activeTool) {
    if (this.activeTool == activeTool) return; // nothing to do
    assert this.activeTool != null;
    if (activeTool == null) {
      throw new IllegalArgumentException("Active tool cannot be null");
    }

    // deactivate old tool
    this.activeTool.deactivate();
    eventService.publish(new ToolDeactivatedEvent(this.activeTool));

    // activate new tool
    this.activeTool = activeTool;
    activeTool.activate();
    eventService.publish(new ToolActivatedEvent(activeTool));
  }
Пример #4
0
 @Override
 public boolean remove(final Object o) {
   if (!(o instanceof ModuleInfo)) return false;
   final ModuleInfo info = (ModuleInfo) o;
   final ShadowMenu node = removeInternal(info);
   if (node == null) return false;
   if (es != null) es.publish(new MenusRemovedEvent(node));
   return true;
 }
Пример #5
0
  /**
   * Adds the given module to the menu structure. If the module is not visible (i.e., {@link
   * ModuleInfo#isVisible()} returns false), it is ignored.
   *
   * <p>{@inheritDoc}
   */
  @Override
  public boolean add(final ModuleInfo o) {
    if (!o.isVisible()) return false;

    final ShadowMenu node = addInternal(o);
    if (node == null) return false;
    if (es != null) es.publish(new MenusAddedEvent(node));
    return true;
  }
Пример #6
0
 /**
  * Adds the given modules to the menu structure. If a module is not visible (i.e., {@link
  * ModuleInfo#isVisible()} returns false), it is ignored.
  *
  * <p>{@inheritDoc}
  */
 @Override
 public boolean addAll(final Collection<? extends ModuleInfo> c) {
   final HashSet<ShadowMenu> nodes = new HashSet<>();
   for (final ModuleInfo info : c) {
     if (!info.isVisible()) continue;
     final ShadowMenu node = addInternal(info);
     if (node != null) nodes.add(node);
   }
   if (nodes.isEmpty()) return false;
   if (es != null) es.publish(new MenusAddedEvent(nodes));
   return true;
 }
Пример #7
0
 /**
  * Updates the menu structure to reflect changes in the given modules. Does nothing unless at
  * least one of the modules is already in the menu structure.
  *
  * @return true if at least one module was successfully updated
  */
 public boolean updateAll(final Collection<? extends ModuleInfo> c) {
   final HashSet<ShadowMenu> nodes = new HashSet<>();
   for (final ModuleInfo info : c) {
     final ShadowMenu removed = removeInternal(info);
     if (removed == null) continue; // was not in menu structure
     final ShadowMenu node = addInternal(info);
     if (node != null) nodes.add(node);
   }
   if (nodes.isEmpty()) return false;
   if (es != null) es.publish(new MenusUpdatedEvent(nodes));
   return true;
 }
Пример #8
0
 @Override
 public boolean removeAll(final Collection<?> c) {
   final HashSet<ShadowMenu> nodes = new HashSet<>();
   for (final Object o : c) {
     if (!(o instanceof ModuleInfo)) continue;
     final ModuleInfo info = (ModuleInfo) o;
     final ShadowMenu node = removeInternal(info);
     if (node != null) nodes.add(node);
   }
   if (nodes.isEmpty()) return false;
   if (es != null) es.publish(new MenusRemovedEvent(nodes));
   return true;
 }
Пример #9
0
  /** Generate the different intensity profiles from drawn objects for each ImageDisplay */
  public void generateTrainingSet() {

    double maxDiameter = 0.0;

    List<ImageDisplay> displays = imageDisplayService.getImageDisplays();
    imgDatasets = new ArrayList<>(displays.size());
    List<Dataset> labeledDs = new ArrayList<>(displays.size());
    List<List<Overlay>> overlaySet = new ArrayList<>();

    displays
        .stream()
        .forEach(
            id -> {
              imgDatasets.add(imageDisplayService.getActiveDataset(id));
              overlaySet.add(overlayService.getOverlays(id));
            });

    int numProfiles = 0;
    for (int ds = 0; ds < imgDatasets.size(); ds++) {

      labeledDs.add(imagePlaneService.createEmptyPlaneDataset(imgDatasets.get(ds)));
      ArrayList<Point2D> centers = new ArrayList<>();

      for (Overlay o : overlaySet.get(ds)) {

        OverlayShapeStatistics stats = overlayStatService.getShapeStatistics(o);
        centers.add(stats.getCenterOfGravity());

        if (stats.getFeretDiameter() > maxDiameter) maxDiameter = stats.getFeretDiameter();

        overlayDrawingService.drawOverlay(
            o, OverlayDrawingService.OUTLINER, labeledDs.get(ds), COLOR);
      }
      //            uis.show(labeledDs.get(ds));
      ProfilesSet profiles = new DefaultProfilesSet(centers, (int) maxDiameter, context);
      generateConfirmationSet(profiles, labeledDs.get(ds));
      numProfiles += profiles.size();
      trainingData.add(profiles);
    }
    eventService.publish(new ProfileEvent(ProfileType.TRAIN, numProfiles));
  }
Пример #10
0
  @Override
  public void setCurrentTool(Class<? extends FxTool> currentToolCl) {

    this.currentTool = getTool(currentToolCl);
    eventService.publish(new ToolChangeEvent(currentTool));
  }
Пример #11
0
 @Override
 public void addModule(final ModuleInfo module) {
   if (moduleIndex.add(module)) {
     eventService.publish(new ModulesAddedEvent(module));
   }
 }
Пример #12
0
 @Override
 public void removeModules(final Collection<? extends ModuleInfo> modules) {
   if (moduleIndex.removeAll(modules)) {
     eventService.publish(new ModulesRemovedEvent(modules));
   }
 }
Пример #13
0
 @Override
 public void addModules(final Collection<? extends ModuleInfo> modules) {
   if (moduleIndex.addAll(modules)) {
     eventService.publish(new ModulesAddedEvent(modules));
   }
 }
Пример #14
0
 @Override
 public void removeModule(final ModuleInfo module) {
   if (moduleIndex.remove(module)) {
     eventService.publish(new ModulesRemovedEvent(module));
   }
 }