I just edited the code used to add labels.
The following code should compute the mean value over the area covered by the object; it seems working but it's too slow:
if (this.gprops.showLabels)
{
g.pen = penLabel;
var width = imageWnd.mainView.image.width;
var height = imageWnd.mainView.image.height;
for (var i = 0; i < objects.length; i++)
if (objects[i]!=null && drawInfo[i])
{
var sum=0.0;
var cont=0;
var radius = objects[i].diameter / 2 / metadata.resolution;
var radius_2 = Math.pow(radius, 2);
for (var m=Math.max(drawInfo[i].pI.x-radius,0); m<Math.min(drawInfo[i].pI.x+radius, width); m++)
for (var n=Math.max(drawInfo[i].pI.y-radius,0); n<Math.min(drawInfo[i].pI.y+radius, height); n++)
//if (Math.pow(m-drawInfo[i].pI.x,2)+Math.pow(n-drawInfo[i].pI.y,2)<radius_2)
if ((m-drawInfo[i].pI.x)*(m-drawInfo[i].pI.x)+(n-drawInfo[i].pI.y)*(n-drawInfo[i].pI.y)<radius_2)
{
sum+=imageWnd.mainView.image.sample(m,n, 0);
cont++;
}
//console.writeln("cont: ", cont);
//if (imageWnd.mainView.image.sample(drawInfo[i].pI.x,drawInfo[i].pI.y, 0) >0.2)
if (sum/cont>0.2)
for (var l = 0; l < 8; l++)
this.DrawLabel(g, objects[i], this.gprops.labelFields[l], l, font, drawInfo[i].size + hole, drawInfo[i].pI, graphicsScale);
}
}
What is wrong? Could speed be related to image.sample?
Thanks again
Armando