[ITK] [ITK-users] Undefined references to methods of template classes
Matt McCormick
matt.mccormick at kitware.com
Wed Jan 14 20:30:21 EST 2015
Hi Francisco,
Great to hear about the progress!
The itk::BinaryImageToShapeLabelMapFilter requires a binary input,
which should have an integer pixel type, like unsigned char or
unsigned short. It is important to set the BackgroundValue and
ForegroundValue [1] to get this filter to work correctly.
HTH,
Matt
[1] http://www.itk.org/Doxygen/html/classitk_1_1BinaryImageToShapeLabelMapFilter.html
On Wed, Jan 14, 2015 at 5:05 PM, Francisco Lopez de la Franca
<franciscolopezdelafranca at gmail.com> wrote:
> Hi again.
> I fixed all the errors and got my library, now ready to be tested.
> It contains an encapsulation, on the one hand, of the class
> itkBinaryImageToShapeLabelMapFilter in order to get image shape descriptors
> of a 3D binary image, and on the other hand, the same for the class
> itkScalarImageToTextureFeaturesFilter to get image texture features of a 3D
> scalar image.
>
> I pass as input image to both classes a binary 3D Nifti image (150x150x150)
> containing a cylinder where the inside voxels are 255 and the outside voxels
> are 0.
>
> As for the shape issue, it's very strange to me that the call to
> GetNumberOfLabelObjects on a itk::LabelMap object returns a value of 0. The
> main code is as follows:
>
> binaryImageToShapeLabelMapFilter->SetInput(_input);
> binaryImageToShapeLabelMapFilter->ComputePerimeterOn();
> binaryImageToShapeLabelMapFilter->Update();
>
> LabelMapType::Pointer labelMap =
> binaryImageToShapeLabelMapFilter->GetOutput();
>
> int nrOfLabelObjects = labelMap->GetNumberOfLabelObjects();
>
>
> And, as for the texture features, the result of the filter does not seem to
> be very logic:
>
> Energy = 1
> Entropy = 0
> Correlation = 1
> Local Homogeneity = 0
> Inertia = 0
> Cluster Shade = 0
> Cluster Prominence = 0
>
> I've also tested this with a scalar 3D Nifti image and the results are the
> same.
>
> And the question is: What kind of image do I have to pass to the filters so
> that the code would return a more logic expected answer?
>
> Thank you very much in advance.
> My best regars.
> /Francisco
>
> 2015-01-10 22:38 GMT+01:00 Matt McCormick <matt.mccormick at kitware.com>:
>>
>> Hi Francisco,
>>
>> Nice to hear about the progress!
>>
>> You will need to link your library to the ITK libraries:
>>
>> target_link_libraries( mylibrary ${ITK_LIBRARIES} )
>>
>> HTH,
>> Matt
>>
>> On Sat, Jan 10, 2015 at 4:16 PM, Francisco Lopez de la Franca
>> <franciscolopezdelafranca at gmail.com> wrote:
>>>
>>> Thanks to your previous answer the problem was solved, but another one
>>> has come out. It occurs when linking to create the library. It gives an
>>> undefined reference to itk::ExceptionObject::ExceptionObject... as you can
>>> see below.
>>> What it is strange to me is that before including explicit template
>>> instantiation, I created the library without errors, and now that I include
>>> that, I get this error.
>>> I'll appreciate very much any help.
>>>
>>> Linking CXX shared library libTFM_Features.dll
>>>
>>> CMakeFiles\TFM_Features.dir/objects.a(TFM_Features.cpp.obj):TFM_Features.cpp:(.t
>>>
>>> ext$_ZN3itk21MemoryAllocationErrorC1ERKSsjS2_S2_[_ZN3itk21MemoryAllocationErrorC
>>> 1ERKSsjS2_S2_]+0x35): undefined reference to
>>> `itk::ExceptionObject::ExceptionObj
>>> ect(std::string const&, unsigned int, std::string const&, std::string
>>> const&)'
>>>
>>> CMakeFiles\TFM_Features.dir/objects.a(TFM_Features.cpp.obj):TFM_Features.cpp:(.t
>>>
>>> ext$_ZN3itk21MemoryAllocationErrorC1ERKSsjS2_S2_[_ZN3itk21MemoryAllocationErrorC
>>> 1ERKSsjS2_S2_]+0x40): undefined reference to `vtable for
>>> itk::MemoryAllocationEr
>>> ror'
>>>
>>> C:/CV/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-min
>>> gw32/bin/ld.exe:
>>> CMakeFiles\TFM_Features.dir/objects.a(TFM_Features.cpp.obj): ba
>>> d reloc address 0x40 in section
>>> `.text$_ZN3itk21MemoryAllocationErrorC1ERKSsjS2_
>>> S2_[_ZN3itk21MemoryAllocationErrorC1ERKSsjS2_S2_]'
>>> collect2.exe: error: ld returned 1 exit status
>>> SRC\CMakeFiles\TFM_Features.dir\build.make:219: recipe for target
>>> 'SRC/libTFM_Fe
>>> atures.dll' failed
>>> mingw32-make[2]: *** [SRC/libTFM_Features.dll] Error 1
>>> CMakeFiles\Makefile2:77: recipe for target
>>> 'SRC/CMakeFiles/TFM_Features.dir/all'
>>> failed
>>> mingw32-make[1]: *** [SRC/CMakeFiles/TFM_Features.dir/all] Error 2
>>> Makefile:74: recipe for target 'all' failed
>>> mingw32-make: *** [all] Error 2
>>>
>>>
>>> 2015-01-09 21:02 GMT+01:00 Matt McCormick <matt.mccormick at kitware.com>:
>>>>
>>>> Hi Francisco,
>>>>
>>>> In order for the templates to be available in the library, they must
>>>> be explicitly instantiated [1].
>>>>
>>>> HTH,
>>>> Matt
>>>>
>>>> [1] http://www.cplusplus.com/articles/1C75fSEw/
>>>>
>>>> On Fri, Jan 9, 2015 at 2:59 PM, Francisco Lopez de la Franca
>>>> <franciscolopezdelafranca at gmail.com> wrote:
>>>> > Hi.
>>>> > I' like to create a library containing, for example, one template
>>>> > class with
>>>> > a number of methods.
>>>> > I've programmed a simple example and the compilation and generation of
>>>> > the
>>>> > library goes fine. I use the cmake "add_library" command for
>>>> > generating the
>>>> > library.
>>>> >
>>>> > The problem arises at the moment of testing the library. I get an
>>>> > undefined
>>>> > reference for every method in the template class.
>>>> >
>>>> > I've downloaded a tool to look in the contents (functions) of dynamic
>>>> > libraries, and there is no function in the library. If I add another
>>>> > class
>>>> > (not a template class), then, this tool shows me only the functions in
>>>> > this
>>>> > latter class.
>>>> >
>>>> > Has anyone ever come across with this problem?
>>>> >
>>>> > Thanks a lot in advance.
>>>> > Regards
>>>> > /Francisco
>>>> >
>>>> > _____________________________________
>>>> > Powered by www.kitware.com
>>>> >
>>>> > Visit other Kitware open-source projects at
>>>> > http://www.kitware.com/opensource/opensource.html
>>>> >
>>>> > Kitware offers ITK Training Courses, for more information visit:
>>>> > http://www.kitware.com/products/protraining.php
>>>> >
>>>> > 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://public.kitware.com/mailman/listinfo/insight-users
>>>> >
>>>
>>>
>>
>
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
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://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list