Getting data out of ROI

Hi, we are writing a plugin for imagej which is related to a project for forensic Medicine.

Our program needs to take data from ROI’s measure button (inside ROI manager), which shows area for versatile wand tool and length for line tool. User can take these data but we need our program to take them automatically for easy use.

We cannot use macro as we will be computing some other information on the background.

Result table gives this following error:

java:465: error: cannot find symbol
            ResultsTable table =overlay.measure(overlayedImage);

Our code is as follows for this part :

RoiManager roimanager = new RoiManager();
Roi selectedroi = roimanager.getRoi(selectedIndex);

Overlay overlay = selectedroi.getPrototypeOverlay();
ImagePlus overlayedImage = selectedroi.getImage();

ResultsTable table =overlay.measure(overlayedImage);
float[] test = table.getColumn(1);

Is there another way to get measure data from ROI ? Or can we use resultstable for this operation ?

Hi,

I will propose another method.
If you need only perimeter value of ROI, you just calculate it.

for example:
*As I don’t use RoiManager very much, there may be mistakes,
*If you need any other values, please see plugin>filter>Analyzer.java

RoiManager rm = RoiManager.getRoiManager();
HashMap<Integer, Double> lengthMap = new HashMap<>();
//HashMap may not be referenced from within the stream.
//At that time, simply change to the "for".

Arrays.stream(rm.getIndexes()).forEach(index ->{
 Roi selectedroi = roimanager.getRoi(index);
 double length = selectedroi.getLength;
 lengthMap.put(index, length);
});

I hope this will be a clue.

hwada