[ITK] [ITK-users] Texture pixel by pixel

Francisco Lopez de la Franca franciscolopezdelafranca at gmail.com
Wed Feb 10 06:53:21 EST 2016


Hi Bradley again.
I'm modifying your class in order to be able to set a mask image (a binary
image) to be used as a limit in the histogram calculations, I mean, I set
an input, a mask and the class should take into account to calculate the
histograms only the voxels that belong to the input and to the mask image
and having the value 1 in the mask image.
The changes seem to be easy but I don´t know why my tests are not working.
It seems that 2 threads are working at the same time and when I added my
mask iterator, the code crashes.

*** Consider that the input and mask images are the same origin, spacing
and size.

I attach the main changes I've done, and I would thank you a lot if you
don't mind having a look and help me to find what I'm doing wrong:

template< class TImageType, class TOutputImage >
void
TextureFeatureImageFilterV2< TImageType, TOutputImage
>::*SetInput*(InputImageType
*image)
{
  // Process object is not const-correct so the const_cast is required here
  this->ProcessObject::SetNthInput( 0,
                                    const_cast< InputImageType * >( image )
);
}

template< class TImageType, class TOutputImage >
void
TextureFeatureImageFilterV2< TImageType, TOutputImage
>::*SetMaskImage*(InputImageType
*image)
{
  // Process object is not const-correct so the const_cast is required here
  this->ProcessObject::SetNthInput( 1, const_cast< InputImageType * >(
image ) );

  _maskImage = image; // _maskImage is a private member
}

In the *ThreadedGenerateData*(const RegionType& outputRegionForThread,
ThreadIdType threadId ) method:
{

...

  for ( fit = faceList.begin(); fit != faceList.end(); ++fit )
    {
    NeighborhoodIteratorType nIter( radius, input, *fit );
    *NeighborhoodIteratorType maskIter( radius, _maskImage, *fit);*
    OutputIterator           outIter(output, *fit);

    OutputPixelType out;
    NumericTraits<OutputPixelType>::SetLength( out,
this->GetNumberOfOutputComponents() );

    while( !nIter.IsAtEnd() )
      {
      this->FillHistogram( *histogram, nIter, *maskIter *);

      ...

      ++nIter;
      ++outIter;
     * ++maskIter;*
    ...

In the *FillHistogram *method:
{

...

  while( iter != m_CooccurenceOffsetVector.end() )
    {

    const PixelType p1 = niter.GetPixel(iter->first);
    const PixelType p2 = niter.GetPixel(iter->second);
    std::cout << "Before p3" << std::endl;

*    const PixelType p3 = maskIter.GetPixel(iter->first);    *std::cout <<
"After p3: " << p3 << std::endl;

*    const PixelType p4 = maskIter.GetPixel(iter->second);   * std::cout <<
"After p4: " << p4 << std::endl;

    if (    p1 >= m_Min && p2 >= m_Min && p1 <= m_Max && p2 <= m_Max
            *&& p3 == _insidePixelValue && p4 == _insidePixelValue* ) //
The point
      {

...


*THE CODE PRINTS TWICE "BEFORE P3" AND CRASHES.*

Thank you so much.
My kind regards.
/Paco

2016-01-25 12:50 GMT+01:00 Francisco Lopez de la Franca <
franciscolopezdelafranca at gmail.com>:

> Hello Bradley again.
> Sorry but I'd like to re-open this issue because I need your class but
> with some modification.
> I pass to tell you.
>
> As my tests with your external class were not good taking into account the
> performance, I wonder if you could create a variant of it, but in which I
> can set a mask image and your class just return the VectorImage with all
> the features for that region (the masked locations) as
> itk::ScalarImageToTextureFeaturesFilter class does.
> I mean, to get the vector image with all the features but just calculate
> it for the regions belonging to the mask image. Positions not belonging to
> the mask region could have a pixel value of 0, for instance.
>
> I don´t know if it is very costly for you,  but I would thank you so much.
> Otherwise, I could try it but I'd need your suggestions on how to do it.
>
> Thanks a lot.
> Best regards.
>
> 2015-09-30 23:38 GMT+02:00 Francisco Lopez de la Franca <
> franciscolopezdelafranca at gmail.com>:
>
>> Hello Bradley again,
>> I would like to ask you for a couple of favours. In the one hand, could
>> you please send me your 3D image so that I can test on it? And on the other
>> hand, could you test the example I have referenced in the previous email
>> with your image, not changing anything in the code, such as it is, and tell
>> me if the execution time is normal?
>> Thank you very much.
>> Regards,
>> /Francisco
>>
>> PS: All my application trace is printed via standard 'cout' command, not
>> due to a debugging compilation mode.
>>
>>
>> El miércoles, 30 de septiembre de 2015, Bradley Lowekamp <
>> blowekamp at mail.nih.gov> escribió:
>>
>>> Hello,
>>>
>>> Did you compile TextureFeatureImage in Release mode?
>>>
>>> 1) The filter does not scale well with a large radius. And given by your
>>> initial report of print a very large number of offset you, it sounds like
>>> you are using a large radius with many offsets. I created a 224x224x300
>>> unsigned short image and ran with the default offset and a radius of 2 in 5
>>> minutes on my laptop. When I wrote this filter is was ~10x faster than this
>>> example... things change though...
>>>
>>>
>>> 2) I sounds like the boundaries/limits of the histogram may be clipping
>>> you values. I would inspect the co-occurance matrix.
>>>
>>>
>>> HTH,
>>> Brad
>>>
>>> On Sep 30, 2015, at 3:28 AM, Francisco Lopez de la Franca <
>>> franciscolopezdelafranca at gmail.com> wrote:
>>>
>>> I've tested with itkTextureFeatureImageFilter, with
>>> itk::ScalarImageToTextureFeaturesFilter and also with the
>>> http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures example,
>>> for a 3D image and here are my comments:
>>>
>>>
>>> 1. I had to interrupt the test after several hours and it kept on
>>> calculating. And this is for only a 3D image (224x224x300). I need to
>>> process around 35 images.
>>> 2. The result (texture features: entropy, energy, correlation, LH,
>>> inertia, CS and CP) for every voxel was: [1, 0, 1, 0, 0, 0, 7.83083e+247].
>>> These values were not what I expected based on my experience on another
>>> application I developed, but in that case, I calculated the texture
>>> features for an image as a whole, not voxel by voxel.
>>>
>>> Regards.
>>>
>>> 2015-09-30 8:46 GMT+02:00 vis <itkhelpacc at gmail.com>:
>>>
>>>> i yes i have tried radius = 3;
>>>> still no luck
>>>>
>>>> On Wed, Sep 30, 2015 at 12:06 PM, Francisco López-Franca [via ITK
>>>> Insight
>>>> Users] <ml-node+s2283740n7587961h47 at n2.nabble.com> wrote:
>>>>
>>>> > Have you tried with a radius of 3 instead of 1?
>>>> >
>>>> > 2015-09-30 8:26 GMT+02:00 vis <[hidden email]
>>>> > <http:///user/SendEmail.jtp?type=node&node=7587961&i=0>>:
>>>> >
>>>> >> hey Matt,
>>>> >> thanks for ur advice.. it did build successfully... but im not able
>>>> to run
>>>> >> the code for 2D png image... i tried to change the dimension to 2 and
>>>> >> build
>>>> >> it which it did.. but when i run the code using the command
>>>> >> line itkTextureFeatureImageFilterTest.exe cthead.png putput.png 1...
>>>> i see
>>>> >> this output
>>>> >>
>>>> >> offset: [-1, -1] [0, -1]
>>>> >> offset: [0, -1] [1, -1]
>>>> >> offset: [-1, 0] [0, 0]
>>>> >> offset: [0, 0] [1, 0]
>>>> >> offset: [-1, 1] [0, 1]
>>>> >> offset: [0, 1] [1, 1] and it asks for abort the program... if pls
>>>> tel me
>>>> >> how can i modify this code to work wid 2d image... forgive me if my
>>>> ques
>>>> >> are really silly im trying to learn something..
>>>> >> regards
>>>> >> Vis
>>>> >>
>>>> >> On Wed, Sep 30, 2015 at 2:56 AM, Matt McCormick-2 [via ITK Insight
>>>> Users]
>>>> >> <
>>>> >> [hidden email] <
>>>> http:///user/SendEmail.jtp?type=node&node=7587961&i=1>>
>>>> >> wrote:
>>>> >>
>>>> >> > Hi,
>>>> >> >
>>>> >> > The function:
>>>> >> >
>>>> >> >   itkTextureFeatureImageFilterTest(int argc, char *argv[])
>>>> >> >
>>>> >> > must be renamed to
>>>> >> >
>>>> >> >   main(int argc, char* argv[])
>>>> >> >
>>>> >> > HTH,
>>>> >> > Matt
>>>> >> >
>>>> >> > On Tue, Sep 29, 2015 at 6:08 AM, vis <[hidden email]
>>>> >> > <http:///user/SendEmail.jtp?type=node&node=7587952&i=0>> wrote:
>>>> >> >
>>>> >> > > hi all,
>>>> >> > > im trying to build the itkTextureFeatureImageFilterTest.cxx code
>>>> but
>>>> >> im
>>>> >> > not
>>>> >> > > able to it is showing the following error
>>>> >> > > 1>------ Rebuild All started: Project: ZERO_CHECK, Configuration:
>>>> >> Debug
>>>> >> > x64
>>>> >> > > ------
>>>> >> > > 1>  Checking Build System
>>>> >> > > 1>  CMake does not need to re-run because
>>>> >> > >
>>>> D:/ITK_VTK_EX/My_ITK_Ex/seg/Texture/test/bin/CMakeFiles/generate.stamp
>>>> >> > is
>>>> >> > > up-to-date.
>>>> >> > > 2>------ Rebuild All started: Project:
>>>> >> itkTextureFeatureImageFilterTest,
>>>> >> > > Configuration: Debug x64 ------
>>>> >> > > 2>  Building Custom Rule
>>>> >> > > D:/ITK_VTK_EX/My_ITK_Ex/seg/Texture/test/CMakeLists.txt
>>>> >> > > 2>  CMake does not need to re-run because
>>>> >> > >
>>>> D:\ITK_VTK_EX\My_ITK_Ex\seg\Texture\test\bin\CMakeFiles\generate.stamp
>>>> >> > is
>>>> >> > > up-to-date.
>>>> >> > > 2>  itkTextureFeatureImageFilterTest.cxx
>>>> >> > > 2>C:\Program Files (x86)\Microsoft Visual Studio
>>>> >> > > 11.0\VC\include\xutility(2176): warning C4996: 'std::_Copy_impl':
>>>> >> > Function
>>>> >> > > call with parameters that may be unsafe - this call relies on the
>>>> >> caller
>>>> >> > to
>>>> >> > > check that the passed values are correct. To disable this
>>>> warning, use
>>>> >> > > -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use
>>>> Visual C++
>>>> >> > > 'Checked Iterators'
>>>> >> > > 2>          C:\Program Files (x86)\Microsoft Visual Studio
>>>> >> > > 11.0\VC\include\xutility(2157) : see declaration of
>>>> 'std::_Copy_impl'
>>>> >> > > 2>
>>>> >> > >
>>>> >>
>>>> c:\itk\source\modules\io\imagebase\include\itkImageFileReader.hxx(439) :
>>>> >> > see
>>>> >> > > reference to function template instantiation '_OutIt
>>>> std::copy<const
>>>> >> > > unsigned char*,unsigned char*>(_InIt,_InIt,_OutIt)' being
>>>> compiled
>>>> >> > > 2>          with
>>>> >> > > 2>          [
>>>> >> > > 2>              _OutIt=unsigned char *,
>>>> >> > > 2>              _InIt=const unsigned char *
>>>> >> > > 2>          ]
>>>> >> > > 2>
>>>> >> > >
>>>> >>
>>>> c:\itk\source\modules\io\imagebase\include\itkImageFileReader.hxx(353) :
>>>> >> > > while compiling class template member function 'void
>>>> >> > > itk::ImageFileReader<TOutputImage>::GenerateData(void)'
>>>> >> > > 2>          with
>>>> >> > > 2>          [
>>>> >> > > 2>              TOutputImage=InputImageType
>>>> >> > > 2>          ]
>>>> >> > > 2>
>>>> >> > >
>>>> >> >
>>>> >>
>>>> D:\ITK_VTK_EX\My_ITK_Ex\seg\Texture\test\itkTextureFeatureImageFilterTest.cxx(47)
>>>> >> >
>>>> >> > > : see reference to class template instantiation
>>>> >> > > 'itk::ImageFileReader<TOutputImage>' being compiled
>>>> >> > > 2>          with
>>>> >> > > 2>          [
>>>> >> > > 2>              TOutputImage=InputImageType
>>>> >> > > 2>          ]
>>>> >> > > 2>          C:\Program Files (x86)\Microsoft Visual Studio
>>>> >> > > 11.0\VC\include\xutility(2157) : see declaration of
>>>> 'std::_Copy_impl'
>>>> >> > > 2>          C:\Program Files (x86)\Microsoft Visual Studio
>>>> >> > > 11.0\VC\include\xutility(2157) : see declaration of
>>>> 'std::_Copy_impl'
>>>> >> > > 2>          C:\Program Files (x86)\Microsoft Visual Studio
>>>> >> > > 11.0\VC\include\xutility(2157) : see declaration of
>>>> 'std::_Copy_impl'
>>>> >> > > 2>     Creating library
>>>> >> > >
>>>> >> >
>>>> >>
>>>> D:/ITK_VTK_EX/My_ITK_Ex/seg/Texture/test/bin/Debug/itkTextureFeatureImageFilterTest.lib
>>>> >> >
>>>> >> > > and object
>>>> >> > >
>>>> >> >
>>>> >>
>>>> D:/ITK_VTK_EX/My_ITK_Ex/seg/Texture/test/bin/Debug/itkTextureFeatureImageFilterTest.exp
>>>> >> >
>>>> >> > > 2>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external
>>>> symbol
>>>> >> > main
>>>> >> > > referenced in function __tmainCRTStartup
>>>> >> > >
>>>> >> >
>>>> >>
>>>> 2>D:\ITK_VTK_EX\My_ITK_Ex\seg\Texture\test\bin\Debug\itkTextureFeatureImageFilterTest.exe
>>>> >> >
>>>> >> > > : fatal error LNK1120: 1 unresolved externals
>>>> >> > > 3>------ Rebuild All started: Project: ALL_BUILD, Configuration:
>>>> Debug
>>>> >> > x64
>>>> >> > > ------
>>>> >> > > 3>  Building Custom Rule
>>>> >> > > D:/ITK_VTK_EX/My_ITK_Ex/seg/Texture/test/CMakeLists.txt
>>>> >> > > 3>  CMake does not need to re-run because
>>>> >> > >
>>>> D:\ITK_VTK_EX\My_ITK_Ex\seg\Texture\test\bin\CMakeFiles\generate.stamp
>>>> >> > is
>>>> >> > > up-to-date.
>>>> >> > > ========== Rebuild All: 2 succeeded, 1 failed, 0 skipped
>>>> ==========
>>>> >> > > im using the follwing CMakeList.txt
>>>> >> > > # This is the root ITK CMakeLists file.
>>>> >> > > cmake_minimum_required(VERSION 2.4)
>>>> >> > > if(COMMAND CMAKE_POLICY)
>>>> >> > >   cmake_policy(SET CMP0003 NEW)
>>>> >> > > endif()
>>>> >> > >
>>>> >> > >
>>>> >> > > # This project is designed to be built outside the Insight source
>>>> >> tree.
>>>> >> > > project(HelloWorld)
>>>> >> > >
>>>> >> > > # Find ITK.
>>>> >> > > find_package(ITK REQUIRED)
>>>> >> > > include(${ITK_USE_FILE})
>>>> >> > >
>>>> >> > > add_executable(itkTextureFeatureImageFilterTest
>>>> >> > > itkTextureFeatureImageFilterTest.cxx )
>>>> >> > >
>>>> >> > > target_link_libraries(itkTextureFeatureImageFilterTest
>>>> >> ${ITK_LIBRARIES})
>>>> >> > >
>>>> >> > > please tel me wat the error is??
>>>> >> > >
>>>> >> > >
>>>> >> > >
>>>> >> > > --
>>>> >> > > View this message in context:
>>>> >> >
>>>> >>
>>>> http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-pixel-by-pixel-tp7587867p7587935.html
>>>> >> > > Sent from the ITK Insight Users mailing list archive at
>>>> Nabble.com.
>>>> >> > > _____________________________________
>>>> >> > > 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
>>>> >> >
>>>> >> >
>>>> >> > ------------------------------
>>>> >> > If you reply to this email, your message will be added to the
>>>> discussion
>>>> >> > below:
>>>> >> >
>>>> >> >
>>>> >>
>>>> http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-pixel-by-pixel-tp7587867p7587952.html
>>>> >> > To unsubscribe from [ITK-users] Texture pixel by pixel, click here
>>>> >> > < > .
>>>> >> > NAML
>>>> >> > <
>>>> >>
>>>> http://itk-insight-users.2283740.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>>>> >> >
>>>> >> >
>>>> >>
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> View this message in context:
>>>> >>
>>>> http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-pixel-by-pixel-tp7587867p7587960.html
>>>> >> Sent from the ITK Insight Users mailing list archive at Nabble.com.
>>>> >> _____________________________________
>>>> >> 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
>>>> >
>>>> >
>>>> > ------------------------------
>>>> > If you reply to this email, your message will be added to the
>>>> discussion
>>>> > below:
>>>> >
>>>> >
>>>> http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-pixel-by-pixel-tp7587867p7587961.html
>>>> > To unsubscribe from [ITK-users] Texture pixel by pixel, click here
>>>> > <
>>>> http://itk-insight-users.2283740.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7587867&code=aXRraGVscGFjY0BnbWFpbC5jb218NzU4Nzg2N3wzNzEzNjYzNzk=
>>>> >
>>>> > .
>>>> > NAML
>>>> > <
>>>> http://itk-insight-users.2283740.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-pixel-by-pixel-tp7587867p7587963.html
>>>> Sent from the ITK Insight Users mailing list archive at Nabble.com.
>>>> _____________________________________
>>>> 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
>>>
>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160210/882921d9/attachment-0001.html>
-------------- next part --------------
_____________________________________
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