<div dir="ltr">Try RGBToLuminanceImageFilter<div><br></div><div><a href="http://itk.org/Wiki/ITK/Examples/ImageProcessing/RGBToLuminanceImageFilter">http://itk.org/Wiki/ITK/Examples/ImageProcessing/RGBToLuminanceImageFilter</a><br>
</div><div><br></div><div style>Bill</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 24, 2013 at 5:02 AM, chasank <span dir="ltr">&lt;<a href="mailto:chasank@gmail.com" target="_blank">chasank@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I&#39;m reading a JPEG Image and trying to process a blur filter<br>
(BinomialBlurImageFilter) on it. Because BinomialBlurImageFilter does not<br>
accept RGBImageType, first I&#39;m trying to convert the RGBImageType to<br>
FloatImageType however I&#39;m getting compiling errors; The sample code is<br>
below; What conversion should I do for processing a RGB Image ?<br>
<br>
typedef itk::Image&lt; itk::RGBPixel &lt;unsigned char&gt;,  2 &gt;  RGBImageType;<br>
typedef itk::Image&lt; float, 2 &gt;<br>
FloatImageType;<br>
<br>
        itk::VTKImageToImageFilter&lt; RGBImageType &gt;::Pointer converter =<br>
                itk::VTKImageToImageFilter&lt;RGBImageType&gt; :: New();<br>
        converter-&gt;SetInput(this-&gt;image);<br>
        converter-&gt;Update();<br>
<br>
        itk::CastImageFilter&lt;RGBImageType, FloatImageType&gt;::Pointer caster =<br>
                itk::CastImageFilter&lt;RGBImageType, FloatImageType&gt;::New();<br>
        caster-&gt;SetInput(converter-&gt;GetOutput());<br>
        caster-&gt;Update();<br>
<br>
        itk::BinomialBlurImageFilter&lt; FloatImageType, FloatImageType &gt;<br>
::Pointer blurFilter =<br>
                itk::BinomialBlurImageFilter &lt; FloatImageType,<br>
FloatImageType&gt; ::New();<br>
        blurFilter-&gt;SetInput( caster-&gt;GetOutput() );<br>
        blurFilter-&gt;SetRepetitions(2);<br>
        blurFilter-&gt;Update();<br>
<br>
        itk::CastImageFilter&lt;FloatImageType, RGBImageType&gt;::Pointer caster2<br>
=<br>
                itk::CastImageFilter&lt;FloatImageType, RGBImageType&gt;::New();<br>
        caster2-&gt;SetInput(blurFilter-&gt;GetOutput());<br>
        caster2-&gt;Update();<br>
<br>
/usr/local/include/ITK-4.3/itkConceptChecking.h: In member function &#39;void<br>
itk::Concept::Convertible&lt;T1, T2&gt;::Constraints::constraints() [with T1 =<br>
itk::RGBPixel&lt;unsigned char&gt;, T2 = float]&#39;:<br>
/usr/local/include/ITK-4.3/itkConceptChecking.h:192:   instantiated from<br>
&#39;itk::Concept::Convertible&lt;itk::RGBPixel&amp;lt;unsigned char&gt;, float&gt;&#39;<br>
/usr/local/include/ITK-4.3/itkCastImageFilter.h:116:   instantiated from<br>
&#39;itk::CastImageFilter&lt;itk::Image&amp;lt;itk::RGBPixel&amp;lt;unsigned char&gt;, 2u&gt;,<br>
itk::Image&lt;float, 2u&gt; &gt;&#39;<br>
../Program/program.cpp:67:   instantiated from here<br>
/usr/local/include/ITK-4.3/itkConceptChecking.h:185: error: invalid<br>
static_cast from type &#39;itk::RGBPixel&lt;unsigned char&gt;&#39; to type &#39;float&#39;<br>
/usr/local/include/ITK-4.3/itkCastImageFilter.h: In member function &#39;TOutput<br>
itk::Functor::Cast&lt;TInput, TOutput&gt;::operator()(const TInput&amp;) const [with<br>
TInput = itk::RGBPixel&lt;unsigned char&gt;, TOutput = float]&#39;:<br>
/usr/local/include/ITK-4.3/itkUnaryFunctorImageFilter.hxx:175:<br>
instantiated from &#39;void itk::UnaryFunctorImageFilter&lt;TInputImage,<br>
TOutputImage, TFunction&gt;::ThreadedGenerateData(const typename<br>
TOutputImage::RegionType&amp;, itk::ThreadIdType) [with TInputImage =<br>
itk::Image&lt;itk::RGBPixel&amp;lt;unsigned char&gt;, 2u&gt;, TOutputImage =<br>
itk::Image&lt;float, 2u&gt;, TFunction =<br>
itk::Functor::Cast&lt;itk::RGBPixel&amp;lt;unsigned char&gt;, float&gt;]&#39;<br>
../Program/program.cpp:151:   instantiated from here<br>
/usr/local/include/ITK-4.3/itkCastImageFilter.h:83: error: invalid<br>
static_cast from type &#39;const itk::RGBPixel&lt;unsigned char&gt;&#39; to type &#39;float&#39;<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/RGBImageType-to-FloatImageType-wit-CastImageFilter-tp7583155.html" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/RGBImageType-to-FloatImageType-wit-CastImageFilter-tp7583155.html</a><br>

Sent from the ITK Insight Users mailing list archive at Nabble.com.<br>
_____________________________________<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.php" target="_blank">http://www.kitware.com/products/protraining.php</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>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>