<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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><br></div><div><br></div><div><br><div><div>On Apr 26, 2011, at 9:07 PM, David Doria wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Lately I've needed to run some filters on a VectorImage. The filters only work on single channel inputs. To get around this, my process to filter each channel separately has been:<br><br>1) Use VectorIndexSelectionCastImageFilter to decompose the image into its separate channels<br>
2) In a loop, run a filter on each channel<br>3) Use ImageToVectorImageFilter to assemble the output from the output of the filter on each channel.<br><br>Is this a reasonable process? Is a more automated way to do this?<br>
<br clear="all">Thanks,<br><br>David<br>
<span><ATT00001..txt></span></blockquote></div><br><div>
<span class="Apple-style-span" style="font-size: 12px; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">========================================================</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Bradley Lowekamp<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font class="Apple-style-span" face="Arial"><span class="Apple-style-span" style="font-family: Arial; "><span class="Apple-style-span" style="font-family: Arial; ">Lockheed Martin </span></span></font><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Contractor for</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Office of High Performance Computing and Communications</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">National Library of Medicine<span class="Apple-converted-space"> </span></font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica"><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span>
</div>
<br></div></body></html>