[Insight-users] SpatialObjectToImageFilter run time
Dan Mueller
dan.muel at gmail.com
Wed Feb 6 18:08:05 EST 2013
Hi Cagatay,
I just downloaded the Insight Journal article from here:
http://www.insight-journal.org/browse/publication/117
and successfully** compiled against ITK v4.2.1 (using Microsoft Visual
C++ 2010 Express).
** The only changes I needed to make was to
MaskedSpatialObjectImageFilterTestDriver, because the ITK test setup
has changed:
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include <iostream>
//#include "itkTestMain.h"
//void RegisterTests()
//{
// //Register test methods
// REGISTER_TEST(itkMaskedSpatialObjectToImageFilterTest);
// REGISTER_TEST(itkSpatialObjectToImageFilterTest);
// REGISTER_TEST(itkImageSpatialObjectTest);
//}
int itkMaskedSpatialObjectToImageFilterTest(int argc, char *argv[]);
int main(int argc, char *argv[]) {
return itkMaskedSpatialObjectToImageFilterTest(argc, argv);
}
I was then able to successfully run the following command:
MaskedSpatialObjectToImageTestDriver.exe Toy1.mhd Toy1-out.mha 128 128
128 1.0 1.0 1.0 4.0 2
I suspect the errors you encountered are in your own code. Did you try
to compile the Insight Journal article as-is, without adding your own
code? What compiler are you using?
Cheers, Dan
On 7 February 2013 03:47, Cagatay Bilgin <bilgincc at gmail.com> wrote:
> Hi Dan,
>
> thank you for the prompt response. I do have both v3(3.20) and v4 and
> unfortunately the code does not compile on v3 either. The problem is not v3
> vs v4, but missing variables and typedefs in the class definition
>
> Here are the first few lines from the compilation process
>
> In file included from tkMaskedSpatialObjectToImageFilter.cxx:20:0:
> itkMaskedSpatialObjectToImageFilter.h:73:37: error: ‘OutputImageDimension’
> was not declared in this scope
> itkMaskedSpatialObjectToImageFilter.h:73:57: error: template argument 2 is
> invalid
> itkMaskedSpatialObjectToImageFilter.h:74:20: error: ‘MaskImageType’ is not a
> class or namespace
> itkMaskedSpatialObjectToImageFilter.h:75:20: error: ‘MaskImageType’ is not a
> class or namespace
> itkMaskedSpatialObjectToImageFilter.cxx: In constructor
> ‘itk::MaskedSpatialObjectToImageFilter<TInputSpatialObject,
> TOutputImage>::MaskedSpatialObjectToImageFilter()’:
> itkMaskedSpatialObjectToImageFilter.cxx:43:3: error: ‘m_ChildrenDepth’ was
> not declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:44:3: error: ‘m_Size’ was not
> declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:46:32: error: ‘OutputImageDimension’
> was not declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:48:5: error: ‘m_Spacing’ was not
> declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:49:5: error: ‘m_Origin’ was not
> declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:52:3: error: ‘m_InsideValue’ was not
> declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:53:3: error: ‘m_OutsideValue’ was
> not declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx:54:3: error: ‘m_UseObjectValue’ was
> not declared in this scope
> itkMaskedSpatialObjectToImageFilter.cxx: In member function ‘virtual void
> itk::MaskedSpatialObjectToImageFilter<TInputSpatialObject,
> TOutputImage>::SetupOutputImage()’:
>
> Cagatay
>
>
> On Tue, Feb 5, 2013 at 8:40 PM, Dan Mueller <dan.muel at gmail.com> wrote:
>>
>> Hi Cemal,
>>
>> The problem is in the design of the SpatialObjectToImageFilter. This
>> filter iterates over the entire image and for each pixel queries
>> whether the spatial object resides in the current pixel. The
>> MaskedSpatialObjectToImageFilter attempts to alleviate this issue by
>> only querying the spatial object for pixels which are likely to
>> contain the object. This approach only works for sparse spatial
>> objects i.e. objects which do not fill the entire image. The
>> MaskedSpatialObjectToImageFilter Insight Journal submission was
>> written for ITKv3 and is evidently now broken for ITKv4. Unfortunately
>> I don't have time to help getting it compile with ITKv4.
>>
>> Another approach is improve speed is to iterate only the bounding box
>> of each object. I implemented this approach (though not for
>> SpatialObjects) here:
>>
>> http://code.google.com/p/manageditk/source/browse/trunk/Source/Modules/IntensityFilters/itkGenerateMaskImageFilter.h
>>
>> http://code.google.com/p/manageditk/source/browse/trunk/Source/Modules/IntensityFilters/itkGenerateMaskImageFilter.txx
>> This filter allows you to specify a number of ellipses, boxes, and
>> points to generate a mask image. Again, this code was written for
>> ITKv3 and may not compile with ITKv4...
>>
>> Good luck.
>>
>> Regards, Dan
>>
>> On 6 February 2013 12:50, Cagatay Bilgin <bilgincc at gmail.com> wrote:
>> > Hi, I've been using SpatialObjectToImageFilter for a while to create
>> > synthetic images and have been upset with the run time. For 10 ellipse
>> > objects (3d) the run time is 1 minute, for 20 objects it's around 5
>> > minutes.
>> > Everything is compiled in release mode, and the rest of the kit runs as
>> > expected.
>> >
>> > I found an email on the emailing list where Dan Mueller suggests using
>> > MaskedSpatialObjectToImageFilter
>> >
>> > http://itk-users.7.n7.nabble.com/SpatialObjectToImageFilter-slow-td27261.html
>> > Unfortunately the code does not compile; some typedefs are not defined,
>> > and
>> > some variables are not declared. I tried fixing them and got it to
>> > compile
>> > but when I tried running the example I got a blank image. Do you have
>> > any
>> > suggestions?
>> >
>> > Thanks,
>> > Cagatay
>> >
>> >
>> > --
>> > Cemal Cagatay Bilgin
>> > Life Sciences Division
>> > Lawrence Berkeley National Lab
>> > MS977, One Cyclotron Road
>> > Berkeley, CA 94720, USA
>> > Email: ccbilgin at lbl.gov
>> > _____________________________________
>> > 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://www.itk.org/mailman/listinfo/insight-users
>> >
>
>
>
>
> --
> Cemal Cagatay Bilgin
> Life Sciences Division
> Lawrence Berkeley National Lab
> MS977, One Cyclotron Road
> Berkeley, CA 94720, USA
> Email: ccbilgin at lbl.gov
More information about the Insight-users
mailing list