[Insight-users] Fastest way to label an array

Nicolas Rannou nrannou at bwh.harvard.edu
Mon Jun 29 13:08:27 EDT 2009


Hi all,

I'm currently trying to process an array, to create a label map 
associated to this array.
The problem is that I want a fast processing and the method I use is too 
slow.

What I do:

/------------------------------------------------------------/
for(i...){ // 2 for loops to go through the array
  for(j...){
    for(int k;k=0;k<nbOfLabels){ // A loop to test the value of the 
pixel to know to which label associate it
      if(ArrayToCreateTheLabelMap->GetScalarComponentAsDouble(i,j,...) > 
x && ArrayToCreateTheLabelMap->GetScalarComponentAsDouble(i,j,...) < y){
       ArrayLabelMap->SetScalarComponentFromDouble(i,j) = k; //fill the 
label map
      }
    }
  }
}
/----------------------------------------------------------/
Do you have any suggestion to increase the time of processing?
Maybe should I use something else than Get/SetScalarComponent.
Is it possible to do a fast mapping, to say that all pixels (in the 
array or in a volume) between x and y should be egal to 1, between w and 
z egal to 2... instead of doing these loops?
With 2 labels, the time of processing is ok but as soon as the number of 
label increases, it becomes too long.

Thanks,

Nicolas


More information about the Insight-users mailing list