<div dir="ltr">Hi Cory,<br><br>I use QtCreator, so the cmake lists is auomagically managed by qmake. In fact I don't even know how to create cmakeLists.txt and I never required with QtCreator.<br><br>I have managed to make a simple function as shown below.<br>
<br>It converts 2 vtkImageData into itkImages, both are 3D. The conversion works pretty well and verified with old itkConvolutionImageFilter. Then I convolve with the latest filter. I copied all the necessary files from itk4.0 to the src folder such as itkDivideByConstantImageFilter,....<br>
<br>Hope you will be able to manage with this<br><br><span style=" color:#000080;">#include</span><span style=" color:#008000;">"itkVTKImageToImageFilter.h"</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#include</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"itkImageToVTKImageFilter.h"</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#include</span><span style=" color:#008000;">"itkImage.h"</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#include</span><span style=" color:#008000;">"itkConvolutionImageFilter.h"</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#include</span><span style=" color:#008000;">"vtkImageData.h"</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">#include</span><span style=" color:#008000;">"QDebug"</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">void</span><span style=" color:#c0c0c0;"> </span>main<span style=" color:#000000;">(</span>vtkImageData<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>input<span style=" color:#000000;">,</span>vtkImageData<span style=" color:#000000;">*</span><span style=" color:#c0c0c0;"> </span>kernel<span style=" color:#000000;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000000;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;">//Convert</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">input</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">vtkImageData</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">itkImage</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">typedef</span><span style=" color:#c0c0c0;"> </span>itk<span style=" color:#000000;">::</span>Image<span style=" color:#000000;"><</span><span style=" color:#808000;">unsigned</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#000000;">,</span><span style=" color:#000080;">3</span><span style=" color:#000000;">></span><span style=" color:#c0c0c0;"> </span>ImageType<span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">typedef</span><span style=" color:#c0c0c0;"> </span>itk<span style=" color:#000000;">::</span>VTKImageToImageFilter<span style=" color:#000000;"><</span>ImageType<span style=" color:#000000;">></span>VTKImageToImageType<span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">VTKImageToImageType<span style=" color:#000000;">::</span>Pointer<span style=" color:#c0c0c0;"> </span>converter<span style=" color:#000000;">=</span>VTKImageToImageType<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">converter<span style=" color:#000000;">-></span>SetInput<span style=" color:#000000;">(</span>input<span style=" color:#000000;">-></span>GetOutput<span style=" color:#000000;">());</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">converter<span style=" color:#000000;">-></span>Update<span style=" color:#000000;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;">//Convert</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">kernel</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">vtkImageData</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">to</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">itkImage</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">typedef</span><span style=" color:#c0c0c0;"> </span>itk<span style=" color:#000000;">::</span>Image<span style=" color:#000000;"><</span><span style=" color:#808000;">unsigned</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#000000;">,</span><span style=" color:#000080;">3</span><span style=" color:#000000;">></span><span style=" color:#c0c0c0;"> </span>ImageTypeKernel<span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">typedef</span><span style=" color:#c0c0c0;"> </span>itk<span style=" color:#000000;">::</span>VTKImageToImageFilter<span style=" color:#000000;"><</span>ImageTypeKernel<span style=" color:#000000;">></span>VTKImageToImageTypeKernel<span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">VTKImageToImageTypeKernel<span style=" color:#000000;">::</span>Pointer<span style=" color:#c0c0c0;"> </span>converterKernel<span style=" color:#000000;">=</span>VTKImageToImageTypeKernel<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">converterKernel<span style=" color:#000000;">-></span>SetInput<span style=" color:#000000;">(</span>kernel<span style=" color:#000000;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">converterKernel<span style=" color:#000000;">-></span>Update<span style=" color:#000000;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;">//Crashes</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">while</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">executing</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">htis</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qDebug<span style=" color:#000000;">()<<</span><span style=" color:#008000;">"Convolving...."</span><span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">typedef</span><span style=" color:#c0c0c0;"> </span>itk<span style=" color:#000000;">::</span>ConvolutionImageFilter<span style=" color:#000000;"><</span>ImageType<span style=" color:#000000;">></span><span style=" color:#c0c0c0;"> </span>ConvolutionFilterType<span style=" color:#000000;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">ConvolutionFilterType<span style=" color:#000000;">::</span>Pointer<span style=" color:#c0c0c0;"> </span>convoluter<span style=" color:#000000;">=</span><span style=" color:#c0c0c0;"> </span>ConvolutionFilterType<span style=" color:#000000;">::</span>New<span style=" color:#000000;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">convoluter<span style=" color:#000000;">-></span>SetInput<span style=" color:#000000;">(</span>converter<span style=" color:#000000;">-></span>GetOutput<span style=" color:#000000;">());</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">convoluter<span style=" color:#000000;">-></span>SetImageKernelInput<span style=" color:#000000;">(</span>converterKernel<span style=" color:#000000;">-></span>GetOutput<span style=" color:#000000;">());</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;">//convoluter->SetOutputRegionModeToSame();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">convoluter<span style=" color:#000000;">-></span>Update<span style=" color:#000000;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qDebug<span style=" color:#000000;">()<<</span><span style=" color:#008000;">"Convolving</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">done...."</span><span style=" color:#000000;">;<br>
<br></span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000000;">}<br><br>Thanks<br><br>Jothy<br></span></pre><br><br><div class="gmail_quote">
On Fri, Sep 16, 2011 at 2:23 PM, Cory Quammen <span dir="ltr"><<a href="mailto:cquammen@cs.unc.edu">cquammen@cs.unc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Jothy,<br>
<br>
Could you post a minimal compilable and runnable example with an<br>
accompanying CMakeLists.txt file that gives the compilation error?<br>
<br>
Thanks,<br>
Cory<br>
<div><div></div><div class="h5"><br>
On Fri, Sep 16, 2011 at 7:39 AM, Jothy <<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I am trying to use the itkConvolutionImageFilter from git (since some of the<br>
> bugs are fixed in this). i was able to sucessfully use the older version of<br>
> this downloaded from the Insight journal. But I get the following errors<br>
> with the git version.<br>
><br>
> In file included from ..\BIOSIM2\/itkConvolutionImageFilter.h:197,<br>
><br>
> from ..\BIOSIM2\myimagefilters.cpp:48:<br>
><br>
> ..\BIOSIM2\/itkConvolutionImageFilter.hxx: In member function 'typename<br>
> itk::ConvolutionImageFilter<TInputImage, TKernelImage,<br>
> TOutputImage>::OutputRegionType itk::ConvolutionImageFilter<TInputImage,<br>
> TKernelImage, TOutputImage>::GetValidRegion() const [with TInputImage =<br>
> itk::Image<unsigned int, 3u>, TKernelImage = itk::Image<unsigned int, 3u>,<br>
> TOutputImage = itk::Image<unsigned int, 3u>]':<br>
><br>
> ..\BIOSIM2\/itkConvolutionImageFilter.hxx:200: instantiated from 'void<br>
> itk::ConvolutionImageFilter<TInputImage, TKernelImage,<br>
> TOutputImage>::GenerateOutputInformation() [with TInputImage =<br>
> itk::Image<unsigned int, 3u>, TKernelImage = itk::Image<unsigned int, 3u>,<br>
> TOutputImage = itk::Image<unsigned int, 3u>]'<br>
><br>
> ..\BIOSIM2\myimagefilters.cpp:494: instantiated from here<br>
><br>
> ..\BIOSIM2\/itkConvolutionImageFilter.hxx:267: error: passing 'const<br>
> itk::ConvolutionImageFilter<itk::Image<unsigned int, 3u>,<br>
> itk::Image<unsigned int, 3u>, itk::Image<unsigned int, 3u> >' as 'this'<br>
> argument of 'const TInputImage* itk::ImageToImageFilter<TInputImage,<br>
> TOutputImage>::GetInput() [with TInputImage = itk::Image<unsigned int, 3u>,<br>
> TOutputImage = itk::Image<unsigned int, 3u>]' discards qualifiers<br>
><br>
> And here is the code I use to convolve<br>
><br>
> typedef itk::ConvolutionImageFilter<ImageType> ConvolutionFilterType;<br>
><br>
> ConvolutionFilterType::Pointer convoluter= ConvolutionFilterType::New();<br>
><br>
> convoluter->SetInput(converter->GetOutput());<br>
><br>
> convoluter->SetImageKernelInput(converterKernel->GetOutput());<br>
><br>
> convoluter->Update();<br>
><br>
><br>
> Any hints<br>
><br>
> Jothy<br>
><br>
><br>
><br>
><br>
> --<br>
> Jothybasu K Selvaraj<br>
> PhD Student<br>
> University of Liverpool<br>
> Liverpool,UK<br>
><br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Cory Quammen<br>
Research Associate<br>
Department of Computer Science<br>
The University of North Carolina at Chapel Hill<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothybasu K Selvaraj<br>PhD Student<br>University of Liverpool<br>Liverpool,UK<br></div><br>
</div>