Пример #1
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));
  }
Пример #2
0
  public void dummySegmentation() {

    List<Dataset> predictDataset = new ArrayList<>(imgDatasets.size());

    INDArray predict = dummyClassification();
    int currIdx = 0;

    for (int ds = 0; ds < imgDatasets.size(); ds++) {
      List<List<int[]>> profilesSet = testData.get(ds).getProfiles();

      predictDataset.add(imagePlaneService.createEmptyPlaneDataset(imgDatasets.get(ds)));

      Dataset currDataset = predictDataset.get(ds);

      RandomAccess<RealType<?>> randomAccess = currDataset.randomAccess();

      for (List<int[]> p : profilesSet) {
        for (int i = 0; i < p.size(); i++) {
          randomAccess.setPosition(p.get(i)[0], 0);
          randomAccess.setPosition(p.get(i)[1], 1);

          double value = predict.getRow(currIdx).getDouble(i);
          if (value != 0) randomAccess.get().setReal(value);
        }
      }
      Overlay[] overlays = BinaryToOverlay.transform(context, currDataset, true);
      //            List<Overlay> overlayList = Arrays.asList(BinaryToOverlay.transform(context,
      // currDataset, true));
      overlayStatService.setRandomColor(Arrays.asList(overlays));
      ImageDisplay display = new DefaultImageDisplay();
      context.inject(display);
      display.display(currDataset);
      for (Overlay o : overlays) {
        display.display(o);
      }
      uis.show(display);
    }
  }