[Insight-users] How to map the output data from classifier if I use ImageToListAdaptor?

Luis Ibanez luis . ibanez at kitware . com
Tue, 19 Aug 2003 18:39:17 -0400


Hi Zhuang,

Please look at the example in the SoftwareGuide

    http://www . itk . org/ItkSoftwareGuide . pdf

Section 10.3, in particular to the example in
10.3.1 for the Bayesian classifier. pdf-page 468.



1)  The output of the SampleClassifier is a MembershipSample object.
     This object indicates for every value of the input image
     the label of the class to which it has been assigned.

     The result of the classification will be based on the pixel
     values of the input 3D image. The data in the membership object
     will indicate that, for example, pixel value 234 has been labeled
     as belonging to class I, while pixel value 215 has been labeled
     as belonging to class II,.. and so on.

     With this information you can get back to your 3D input image
     and generate a map of labels (or a labeled image). In that case,
     all the pixels that in the original 3D image had value 234, will
     end up having value the label for class I, while all the pixels
     with value 215 will have the label for class II, ... and so on.

     something like the following code will do it:

      ClassifierType::OutputType * membershipSample =
                                         classifier->GetOutput();

      ClassifierType::OutputType::Iterator it =
                                       membershipSample->Begin();
      ClassifierType::OutputType::Iterator end =
                                       membershipSample->End();

       while( it  != end )
         {
        unsigned int pixelLabel = it.GetClassLabel();
        MeasurementVectorType pixelValue =
                            it.GetMeasurementVector();
        }

      (This is shown in the SoftwareGuide example in page 474).

      If your input image was of scalar type, the MeasurementVectorType
      is a FixedArray of length = 1, so you can say that pixels in your
      3D image having values = "pixelValue[0]" will be classified with
      label = "pixelLabel".  You can generate from this a look-up-table
      for producing an image of labels (a labeled image).



2)  About the type errors in your code... it looks like a scope
     problem.

     Could you please post your code ?

     Otherwise it is quite hard to guess the real source of
     the problem.





Regards,


     Luis



--------------------------
zhuang song wrote:
> 
> Hi,
> 
> I am new to use ITK. Here I meet two problems when I use 'make' command 
> to compile the program.
> 
> 1.   I use itk::Statistics::ImageToListAdaptor class to plug a 3D image 
> object into a Sample object.
>     Then I use itk::Statistics::SampleClassifier to do classification. 
> To read out the result,
>     I used  ClassifierType::OutputType * 
> Membership=Classifier->GetOutput().        I don't know how to map the 
> data in the Membership object to the original 3D image.
> 
> 2.  one more quesiton about the compiler,
>  Within a sub-function, there is always error message like:
>    --- `Endpoint' was not declared in this scope;          //  I've 
> defined the data type at the begining of the function.
>    --- conflicting types for `int relativespace[2]';        //  I only 
> defined 'relativespace' as 'double' data type, not as  'int'.
> 
>   I have clearly defined these variables in the function, and I didn't 
> use them anywhere else. What is the possible problem?
> 
> Thanks for help.
> 
> Zhuang
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>