<div class="gmail_quote">On Wed, Apr 27, 2011 at 8:57 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word">Hello David,<div><br></div><div>We are implementing this independent per component filtering in SimpleITK for VectorImages.</div><div><br></div><div>I am curious as to what filters you are finding it useful to run on a per component basis, so that we can try to get those implemented in SimpleITK.</div>
<div><br></div><div>Here is a sample of how we are doing it, it sounds like the same way you are doing it:</div><div><br></div><div><div>template <class TImageType> Image</div><div>LogImageFilter::ExecuteInternalVectorImage ( const Image& inImage1 )</div>
<div>{</div><div> // Define the input and output image types</div><div> typedef TImageType InputImageType;</div><div> typedef typename InputImageType::InternalPixelType ComponentType;</div>
<div><br></div><div> typedef typename itk::Image<ComponentType, InputImageType::ImageDimension> ComponentImageType;</div><div><br></div><div> typedef InputImageType OutputImageType;</div><div><br></div><div> // Get the pointer to the ITK image contained in image1</div>
<div> typename InputImageType::ConstPointer image1 =</div><div> dynamic_cast <const InputImageType*> ( inImage1.GetImageBase() );</div><div><br></div><div> // Check that ITK image pointer was properly retrieved</div>
<div> if ( image1.IsNull() )</div><div> {</div><div> sitkExceptionMacro( "Unexpected template dispatch error!" );</div><div> }</div><div><br></div><div> typedef itk::VectorIndexSelectionCastImageFilter< InputImageType, OutputImageType > ComponentExtratorType;</div>
<div> typename ComponentExtratorType::Pointer extractor = ComponentExtratorType::New();</div><div> extractor->SetInput( image1 );</div><div><br></div><div> typedef itk::ImageToVectorImageFilter<ComponentImageType> ToVectorFilterType;</div>
<div> typename ToVectorFilterType::Pointer toVector = ToVectorFilterType::New();</div><div><br></div><div> unsigned int numComps = image1->GetNumberOfComponentsPerPixel();</div><div> for ( unsigned int i = 0; i < numComps; ++i )</div>
<div> {</div><div> extractor->SetIndex( i );</div><div> extractor->Update();</div><div><br></div><div> Image tmp = this->ExecuteInternal<ComponentImageType>( Image( extractor->GetOutput() ) );</div>
<div><br></div><div> typename ComponentImageType::ConstPointer tempITKImage =</div><div> dynamic_cast <const ComponentImageType*> ( tmp.GetImageBase() );</div><div><br></div><div> toVector->SetNthInput( i, tempITKImage );</div>
<div> }</div><div><br></div><div> toVector->Update();</div><div><br></div><div> return Image( toVector->GetOutput() );</div><div>}</div></div></div></blockquote><div><br>I've needed it on RescaleImageIntensity, smoothing, logical operations
(as sometimes a "binary/mask" image is really an RGB image with each
channel identical), thresholding, etc.<br>
<br>I would go as far as to say all filters should be able to do this (without writing the loop in each one). I'm going to take a look at Juliens solution now. <br>
<br clear="all">David<br></div><div> </div></div><br>