No subject


Tue Jun 23 12:19:35 EDT 2009


   For All Pixels in the 2D Image do:

       Get the pixel intensity

       For all K label values do:

          If  Intensity is > x  and Intensity is < y
               Set pixel label to value K



How are X and Y related to K ?
or are they supposed to be the position in space of
the pixel ?


It actually seems that you are simply quantizing the
intensity levels of your image.  If so, you could do
this a lot easier with a UnaryFunctor filter, for which
you create a functor with the ranges x,y,w,z....

See for example what is done in

    Insight/Examples/Segmentation/WatershedSegmentation1.cxx

with the

    itk::Functor::ScalarToRGBPixelFunctor


You could write a class, similar to the ScalarToRGBPixelFunctor
but, that instead of assigning mapped RGB color values, it will
assign labels.


Running such filter in an image of 300x300 pixels should take
less that 0.1 seconds... (in a modern computer).



     Regards,


           Luis



------------------------------------------------------------------------------------------------
On Tue, Jun 30, 2009 at 12:02 PM, Nicolas RANNOU <nrannou at bwh.harvard.edu>wrote:

> Hi Luis,
>
> I'm working on an VTK image but I can convert it into ITK for processing.
> My "array" is a 2D image, because if I process the whole volume, the time
> of processing is too long (too many pixels to process through my loops).
>
>
> I want to create the label map associated to this 2D image. But the time of
> processing must be short (< 1 second), not depending (or just a little) on
> the number of labels.
> For example, now, the time of processing for a 300*300 array and 6 labels
> is up to 10 seconds!
>
> Which filter would you recommand to me for the conversion into itk ? I
> usually use itkImageToVTKImageFilter and itkVTKImageToImageFilter but I'm
> not sure that it is the "best".
> (I need to get the result of the labelling as a vtkimagedata for
> visualization)
>
> I will have a look at itkImageClassifierFilter to see if it can solve my
> problem!
>
>
> Thanks for your help,
>
>
> Nicolas
>
> On Tue, 30 Jun 2009 11:37:18 -0400, Luis Ibanez <luis.ibanez at kitware.com>
> wrote:
> > Hi Nicolas,
> >
> > Could you please provide more context ?
> >
> > Are you doing this with ITK images ?
> >
> > Are you doing this with VTK images ?
> >
> >
> > What you call an "array" is it really a 2D image ?
> > or a 3D image ?
> >
> >
> > The relationship between the "array" and the
> > label map is not clearly described in your email.
> >
> >
> > ...
> >
> > At first sight, you seem to be trying to rewrite the
> > functionalities of the itkImageClassifierFilter...
> >
> >
> >
> >     Thanks for any clarifications,
> >
> >
> >             Luis
> >
> >
> > ----------------------------------------------------
> > On Mon, Jun 29, 2009 at 1:08 PM, Nicolas Rannou
> > <nrannou at bwh.harvard.edu>wrote:
> >
> >> 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
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Please keep messages on-topic and check the ITK FAQ at:
> >> http://www.itk.org/Wiki/ITK_FAQ
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.itk.org/mailman/listinfo/insight-developers
> >>
>
>

--00148534934054cdd0046d941da7
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Nicolas,<br><br>Thanks for the clarification.<br><br>10 seconds for labe=
lling a 300x300 pixels image <br>seems to be indeed a very long time.<br><b=
r>It is still not clear to me what is the rule that <br>you are using for l=
abeling every individual pixel.<br>
<br>From your first email it seems that your pseudo-code is<br><br><br>=A0=
=A0 For All Pixels in the 2D Image do:<br><br>=A0=A0=A0=A0=A0=A0 Get the pi=
xel intensity<br><br>=A0=A0=A0=A0=A0=A0 For all K label values do:<br><br>=
=A0 =A0 =A0=A0=A0=A0=A0 If=A0 Intensity is &gt; x=A0 and Intensity is &lt; =
y <br>
=A0=A0 =A0 =A0 =A0=A0=A0=A0=A0=A0=A0 Set pixel label to value K<br><br><br>=
<br>How are X and Y related to K ?<br>or are they supposed to be the positi=
on in space of <br>the pixel ?<br><br><br>It actually seems that you are si=
mply quantizing the<br>
intensity levels of your image.=A0 If so, you could do<br>this a lot easier=
 with a UnaryFunctor filter, for which<br>you create a functor with the ran=
ges x,y,w,z....<br><br>See for example what is done in<br><br>=A0=A0=A0 Ins=
ight/Examples/Segmentation/WatershedSegmentation1.cxx<br>
<br>with the <br><br>=A0=A0=A0 itk::Functor::ScalarToRGBPixelFunctor<br><br=
><br>You could write a class, similar to the ScalarToRGBPixelFunctor<br>but=
, that instead of assigning mapped RGB color values, it will<br>assign labe=
ls.<br>
<br><br>Running such filter in an image of 300x300 pixels should take <br>l=
ess that 0.1 seconds... (in a modern computer).<br><br><br><br>=A0=A0=A0=A0=
 Regards,<br><br><br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Luis<br><br><br><br>---=
---------------------------------------------------------------------------=
------------------<br>
<div class=3D"gmail_quote">On Tue, Jun 30, 2009 at 12:02 PM, Nicolas RANNOU=
 <span dir=3D"ltr">&lt;<a href=3D"mailto:nrannou at bwh.harvard.edu">nrannou at b=
wh.harvard.edu</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" s=
tyle=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8e=
x; padding-left: 1ex;">
Hi Luis,<br>
<br>
I&#39;m working on an VTK image but I can convert it into ITK for processin=
g.<br>
My &quot;array&quot; is a 2D image, because if I process the whole volume, =
the time<br>
of processing is too long (too many pixels to process through my loops).<br=
>
<br>
<br>
I want to create the label map associated to this 2D image. But the time of=
<br>
processing must be short (&lt; 1 second), not depending (or just a little) =
on<br>
the number of labels.<br>
For example, now, the time of processing for a 300*300 array and 6 labels<b=
r>
is up to 10 seconds!<br>
<br>
Which filter would you recommand to me for the conversion into itk ? I<br>
usually use itkImageToVTKImageFilter and itkVTKImageToImageFilter but I&#39=
;m<br>
not sure that it is the &quot;best&quot;.<br>
(I need to get the result of the labelling as a vtkimagedata for<br>
visualization)<br>
<br>
I will have a look at itkImageClassifierFilter to see if it can solve my<br=
>
problem!<br>
<br>
<br>
Thanks for your help,<br>
<br>
<br>
Nicolas<br>
<br>
On Tue, 30 Jun 2009 11:37:18 -0400, Luis Ibanez &lt;<a href=3D"mailto:luis.=
ibanez at kitware.com">luis.ibanez at kitware.com</a>&gt;<br>
wrote:<br>
<div><div></div><div class=3D"h5">&gt; Hi Nicolas,<br>
&gt;<br>
&gt; Could you please provide more context ?<br>
&gt;<br>
&gt; Are you doing this with ITK images ?<br>
&gt;<br>
&gt; Are you doing this with VTK images ?<br>
&gt;<br>
&gt;<br>
&gt; What you call an &quot;array&quot; is it really a 2D image ?<br>
&gt; or a 3D image ?<br>
&gt;<br>
&gt;<br>
&gt; The relationship between the &quot;array&quot; and the<br>
&gt; label map is not clearly described in your email.<br>
&gt;<br>
&gt;<br>
&gt; ...<br>
&gt;<br>
&gt; At first sight, you seem to be trying to rewrite the<br>
&gt; functionalities of the itkImageClassifierFilter...<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; =A0 =A0 Thanks for any clarifications,<br>
&gt;<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 =A0 =A0 Luis<br>
&gt;<br>
&gt;<br>
&gt; ----------------------------------------------------<br>
&gt; On Mon, Jun 29, 2009 at 1:08 PM, Nicolas Rannou<br>
&gt; &lt;<a href=3D"mailto:nrannou at bwh.harvard.edu">nrannou at bwh.harvard.edu=
</a>&gt;wrote:<br>
&gt;<br>
&gt;&gt; Hi all,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m currently trying to process an array, to create a label ma=
p<br>
&gt; associated<br>
&gt;&gt; to this array.<br>
&gt;&gt; The problem is that I want a fast processing and the method I use =
is too<br>
&gt;&gt; slow.<br>
&gt;&gt;<br>
&gt;&gt; What I do:<br>
&gt;&gt;<br>
&gt;&gt; /------------------------------------------------------------/<br>
&gt;&gt; for(i...){ // 2 for loops to go through the array<br>
&gt;&gt; =A0for(j...){<br>
&gt;&gt; =A0 for(int k;k=3D0;k&lt;nbOfLabels){ // A loop to test the value =
of the pixel<br>
&gt; to<br>
&gt;&gt; know to which label associate it<br>
&gt;&gt; =A0 =A0 if(ArrayToCreateTheLabelMap-&gt;GetScalarComponentAsDouble=
(i,j,...) &gt; x<br>
&gt; &amp;&amp;<br>
&gt;&gt; ArrayToCreateTheLabelMap-&gt;GetScalarComponentAsDouble(i,j,...) &=
lt; y){<br>
&gt;&gt; =A0 =A0 =A0ArrayLabelMap-&gt;SetScalarComponentFromDouble(i,j) =3D=
 k; //fill the<br>
&gt; label<br>
&gt;&gt; map<br>
&gt;&gt; =A0 =A0 }<br>
&gt;&gt; =A0 }<br>
&gt;&gt; =A0}<br>
&gt;&gt; }<br>
&gt;&gt; /----------------------------------------------------------/<br>
&gt;&gt; Do you have any suggestion to increase the time of processing?<br>
&gt;&gt; Maybe should I use something else than Get/SetScalarComponent.<br>
&gt;&gt; Is it possible to do a fast mapping, to say that all pixels (in th=
e<br>
&gt; array<br>
&gt;&gt; or in a volume) between x and y should be egal to 1, between w and=
 z<br>
&gt; egal to<br>
&gt;&gt; 2... instead of doing these loops?<br>
&gt;&gt; With 2 labels, the time of processing is ok but as soon as the num=
ber of<br>
&gt;&gt; label increases, it becomes too long.<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt;<br>
&gt;&gt; Nicolas<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Powered by <a href=3D"http://www.kitware.com" target=3D"_blank">ww=
w.kitware.com</a><br>
&gt;&gt;<br>
&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt; <a href=3D"http://www.kitware.com/opensource/opensource.html" targ=
et=3D"_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;<br>
&gt;&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt;&gt; <a href=3D"http://www.itk.org/Wiki/ITK_FAQ" target=3D"_blank">http=
://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;&gt;<br>
&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; <a href=3D"http://www.itk.org/mailman/listinfo/insight-developers"=
 target=3D"_blank">http://www.itk.org/mailman/listinfo/insight-developers</=
a><br>
&gt;&gt;<br>
<br>
</div></div></blockquote></div><br>

--00148534934054cdd0046d941da7--


More information about the Insight-developers mailing list