Reading ROI properties very slow on composite images

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Reading ROI properties very slow on composite images

Straub, Volko A. (Dr.)
I noticed that reading ROI properties appears to be very slow when multichannel images are displayed as a composite, but not when they displayed in color mode. The macro below illustrates the behaviour. It creates a 2-channel image, sets 20 random circular ROIs and assigns each ROI a property called 'Neuron' that is either 'Yes' or 'No'.

Reading out the properties is almost instantaneous when image is displayed in color mode and batch mode is turned on. However, it takes much longer when the display mode for the same image is changed to composite - even with batch mode on.

The problem appears to be image size dependent as increasing the image size slows this further down. Even with batch mode on, the ROI's display on screen appears to be refreshed for each ROI, which presumably is taking up the time.

It is obviously relatively easy to work around by changing the display mode, but I was wondering whether this is an expected behaviour or a bug?


Thanks,

Volko



newImage("Test", "8-bit", 1000, 1000, 2);

for(i=0;i<20;i++){
makeOval(random()*800+100, random()*800+100, 20, 20);
roiManager("add");
roiManager("select", i);
if(random()>0.5){
Roi.setProperty("Neuron","Yes");
Roi.setFillColor("red");
roiManager("update");
}else{
Roi.setProperty("Neuron","No");
Roi.setFillColor("blue");
roiManager("update");
};
};

readRoiProperties();
run("Make Composite", "display=Composite");
readRoiProperties();

function readRoiProperties(){
neuron=0;
other=0;
start=getTime();
setBatchMode(true);
for(i=0;i<roiManager("count");i++){
roiManager("select", i);
if(Roi.getProperty("Neuron")=="Yes"){
neuron=neuron+1;
}else{
other=other+1;
};
};
setBatchMode(false);
end=getTime();
print("Neurons: "+neuron);
print("Others: "+other);
print("Count took: "+end-start+" ms");
}


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html