<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    hm seems that my png file is a jpeg in disguise. i have got no clue
    where this could have happened. I've got it to work with another png
    file. But now i have another issue, the resulting image is just
    black (shoud be canny edges). <br>
    <br>
    Am 24.05.2012 02:17, schrieb Sebastian Losch:
    <blockquote
cite="mid:CAG4NwVqchzrN79dYh59DOe5OkL1zzgZ2Vz_BD0V+WZhxy4Sivw@mail.gmail.com"
      type="cite">Hi Luis,
      <div><br>
      </div>
      <div>&nbsp;i attached the .png file to this email. It's a beauitiful
        picture of myself, shot with a cheap webcam ;)&nbsp;</div>
      <div><br>
      </div>
      <div>Thanks, Sebastian<br>
        <br>
        <div class="gmail_quote">2012/5/24 Luis Ibanez <span dir="ltr">&lt;<a
              moz-do-not-send="true"
              href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>&gt;</span><br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
            Sebastian,
            <div><br>
            </div>
            <div>Could you please send me that .png file ?</div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp;Thanks</div>
            <div>
              <br>
            </div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp; &nbsp; &nbsp; Luis<br>
              <br>
              <br>
              -----------------
              <div>
                <div class="h5"><br>
                  <div class="gmail_quote">On Wed, May 23, 2012 at 7:47
                    PM, Sebastian Losch <span dir="ltr">&lt;<a
                        moz-do-not-send="true"
                        href="mailto:seb.losch@googlemail.com"
                        target="_blank">seb.losch@googlemail.com</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div bgcolor="#FFFFFF" text="#000000"> Hi Luis!<br>
                        <br>
                        Thanks for your response. As i wrote in my first
                        post the .png file is in the same folder as the
                        executable, so that cannot be the reason. When i
                        change the filename to something different (e.g.
                        to a file which does not exists) then itk throws
                        a different exception (file not found). <br>
                        <br>
                        Sebastian<br>
                        <br>
                        Am <a moz-do-not-send="true"
                          href="tel:24.05.2012%2001"
                          value="+12405201201" target="_blank">24.05.2012
                          01</a>:40, schrieb Luis Ibanez:
                        <div>
                          <div>
                            <blockquote type="cite">Hi Sebastian,
                              <div><br>
                              </div>
                              <div>You are using a plain filename
                                (instead of a full path)</div>
                              <div>to point to your image:</div>
                              <div><br>
                              </div>
                              <div>
                                <div><span style="white-space:pre-wrap">
                                  </span>reader-&gt;SetFileName("input.png");</div>
                                <div><br>
                                </div>
                                <br>
                                The factories are telling you that the
                                file</div>
                              <div><br>
                              </div>
                              <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "input.png"</div>
                              <div><br>
                              </div>
                              <div>is not in the same directory that
                                the&nbsp;executable&nbsp;</div>
                              <div>that you build with Visual Studio.</div>
                              <div><br>
                              </div>
                              <div><br>
                              </div>
                              <div>You may want to try one of these tree
                                options:</div>
                              <div><br>
                              </div>
                              <div><br>
                              </div>
                              <div>1) Use a full path to point to your
                                image,</div>
                              <div>&nbsp; &nbsp; &nbsp;something like:</div>
                              <div><br>
                              </div>
                              <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;C:\MyImages\input.png</div>
                              <div>&nbsp; &nbsp;</div>
                              <div>or</div>
                              <div>&nbsp;</div>
                              <div>2) Copy the image to where the
                                executable is</div>
                              <div><br>
                              </div>
                              <div>or</div>
                              <div><br>
                              </div>
                              <div>3) Copy the executable to where the
                                image is</div>
                              <div>&nbsp; &nbsp; and run the executable from that
                                directory<br>
                                <br>
                                <br>
                                <br>
                                Option (1) is probably the best way to
                                go.</div>
                              <div><br>
                              </div>
                              <div><br>
                              </div>
                              <div><br>
                              </div>
                              <div>Ideally your code should have been:</div>
                              <div><br>
                              </div>
                              <div><br>
                              </div>
                              <div>A) If using a command line approach</div>
                              <div><br>
                              </div>
                              <div><span style="white-space:pre-wrap"> </span>reader-&gt;SetFileName(

                                argv[1]&nbsp;);<br>
                              </div>
                              <div>&nbsp;</div>
                              <div>or,</div>
                              <div><br>
                              </div>
                              <div>B) If using a GUI to get the filename
                                from the user:</div>
                              <div><br>
                              </div>
                              <div>&nbsp; &nbsp; &nbsp; const char * filename =
                                GetMeAFileNameFromGUI();</div>
                              <div><br>
                                <div><span style="white-space:pre-wrap">
                                  </span>reader-&gt;SetFileName(
                                  filename );<br>
                                </div>
                                <div><br>
                                </div>
                                <div><br>
                                </div>
                                <div><br>
                                </div>
                                <div>&nbsp; &nbsp;Hope this helps,</div>
                                <div><br>
                                </div>
                                <div><br>
                                </div>
                                <div>&nbsp; &nbsp; &nbsp; &nbsp; Luis</div>
                                <div><br>
                                </div>
                                <div><br>
                                </div>
-----------------------------------------<br>
                                <div class="gmail_quote">On Tue, May 22,
                                  2012 at 4:35 AM, Sebastian Losch <span
                                    dir="ltr">&lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:seb.losch@googlemail.com"
                                      target="_blank">seb.losch@googlemail.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!
                                    <div><br>
                                    </div>
                                    <div>I am having problems getting
                                      the ImageFileReader and
                                      ImageFileWriter to work. I just
                                      want to read a PNG File, apply a
                                      filter and write it back to the
                                      harddrive. I found out that there
                                      is a problem in 4.1 with the
                                      ImageIOFactory registration, so i
                                      register the PNGFactory manually.
                                      The .png file is in the same
                                      folder as the executable. Here is
                                      my Code:</div>
                                    <div><br>
                                    </div>
                                    <div>
                                      <div>#include "itkImage.h"</div>
                                      <div>#include
                                        "itkImageFileReader.h"</div>
                                      <div>#include
                                        "itkImageFileWriter.h"</div>
                                      <div>#include
                                        "itkCannyEdgeDetectionImageFilter.h"</div>
                                      <div>#include
                                        "itkObjectFactoryBase.h"</div>
                                      <div>#include
                                        "itkPNGImageIOFactory.h"</div>
                                      <div><br>
                                      </div>
                                      <div>int main(int argc, char
                                        *argv[])</div>
                                      <div>{</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>itk::ObjectFactoryBase::RegisterFactory(itk::PNGImageIOFactory::New());</div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>double variance = 2.0;</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>double upperThreshold =
                                        0.0;</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>double lowerThreshold =
                                        0.0;</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>typedef
                                        itk::Image&lt;double, 2&gt;
                                        &nbsp;DoubleImageType;</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>typedef
                                        itk::ImageFileReader&lt;DoubleImageType&gt;
                                        ReaderType;</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>ReaderType::Pointer
                                        reader = ReaderType::New();</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>reader-&gt;SetFileName("input.png");</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>typedef
                                        itk::CannyEdgeDetectionImageFilter
                                        &lt;DoubleImageType,
                                        DoubleImageType&gt;</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>CannyEdgeDetectionImageFilterType;</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>CannyEdgeDetectionImageFilterType::Pointer

                                        cannyFilter =
                                        CannyEdgeDetectionImageFilterType::New();</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>cannyFilter-&gt;SetInput(reader-&gt;GetOutput());</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>cannyFilter-&gt;SetVariance(

                                        variance );</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>cannyFilter-&gt;SetUpperThreshold(

                                        upperThreshold );</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>cannyFilter-&gt;SetLowerThreshold(

                                        lowerThreshold );</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>typedef
                                        itk::ImageFileWriter&lt;DoubleImageType&gt;
                                        WriterType;</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>WriterType::Pointer
                                        writer = WriterType::New();</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>writer-&gt;SetFileName("test.png");</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>writer-&gt;SetInput(cannyFilter-&gt;GetOutput());</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>try {</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>writer-&gt;Update();</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>} catch
                                        (itk::ExceptionObject &amp;e) {</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>std::cerr &lt;&lt; e
                                        &lt;&lt; std::endl;</div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>}</div>
                                      <div><br>
                                      </div>
                                      <div><span
                                          style="white-space:pre-wrap">
                                        </span>std::cout &lt;&lt; "ENDE"
                                        &lt;&lt; std::endl;</div>
                                      <div>}</div>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div>and this is the error:</div>
                                    <div><br>
                                    </div>
                                    <div>
                                      <div>itk::ImageFileReaderException
                                        (0059E4A8)</div>
                                      <div>Location: "void __thiscall
                                        itk::ImageFileReader&lt;class
                                        itk::Image&lt;double,2&gt;,class&nbsp;itk::DefaultConvertPixelTraits&lt;double&gt;

&gt;::GenerateOutputInformation(void)"</div>
                                      <div>File:
                                        c:\libs\itk\include\itk-4.1\itkimagefilereader.hxx</div>
                                      <div>Line: 143</div>
                                      <div>Description: &nbsp;Could not
                                        create IO object for file
                                        input.png</div>
                                      <div>&nbsp; Tried to create one of the
                                        following:</div>
                                      <div>&nbsp; &nbsp; PNGImageIO</div>
                                      <div>&nbsp; You probably failed to set
                                        a file suffix, or</div>
                                      <div>&nbsp; &nbsp; set the suffix to an
                                        unsupported type.</div>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div><br>
                                    </div>
                                    <div>What am i doing wrong?</div>
                                    <div><br>
                                    </div>
                                    <div>Thanks in advance, Sebastian</div>
                                    <br>
_____________________________________<br>
                                    Powered by <a
                                      moz-do-not-send="true"
                                      href="http://www.kitware.com"
                                      target="_blank">www.kitware.com</a><br>
                                    <br>
                                    Visit other Kitware open-source
                                    projects at<br>
                                    <a moz-do-not-send="true"
                                      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 moz-do-not-send="true"
                                      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 moz-do-not-send="true"
                                      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 moz-do-not-send="true"
                                      href="http://www.itk.org/mailman/listinfo/insight-users"
                                      target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
                                    <br>
                                  </blockquote>
                                </div>
                                <br>
                              </div>
                            </blockquote>
                            <br>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>