[Insight-users] file reader

Gwenaël Guillard gwenael.guillard@enst-bretagne.fr
Mon, 13 Jan 2003 16:51:29 +0100


--------------9E960C90998B2C497DE28F58
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi,

Thank you for your answer. You are right, the Update( ) is after but the
problem is still there. It seems that the Update( ) method send an exception
The code is


In the main method


            try
            {
              Load( filename );
            }
            catch( ... )
            {
              fl_message("Problem reading the files");
            }

In Load( ) Method


            VolumeReaderType::Pointer Reader =
          VolumeReaderType::New();

            itk::MetaImageIO::Pointer metaImageIO =
          itk::MetaImageIO::New();
            Reader->SetImageIO( metaImageIO );

            Reader->SetFileName( filename );
            printf("avant GetOutput\n");

            PixelType width, height;
            width =
          Reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0];

            height =
          Reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1];

            Reader->Update();
            printf("after Update()\n");

It never writes "after Update()" but it shows the alert message. I'm able to
get width and height  (0 for both because the update is not done yet as you
said). So the problem is when the update is called. I try my data on
gaussianFilter and there wasn't any problem.

Gwenael



Luis Ibanez a écrit :

> Hi Gwenael,
>
> Did you call "Update()" on the reader ?
>
> The output of filters is not valid until
> an Update() call has been issued on them.
> Please make sure that you call "Update()"
> before calling "GetOutput()" on a reader.
>
> You will find many examples of Read/Write
> operations in the Insight/Examples directory.
>
> In particular on the directories:
>
>     Examples/Filtering
>     Examples/IO
>
> You may also want to take a look at the
> SoftwareGuide.pdf document:
> http://public.kitware.com/Insight/Web/HTML/SoftwareGuide.pdf
>
> In particular the chapters:
>
> - "Filtering"
> - "Reading and Writting Images"
>
> Please let us know if you have further questions,
>
>    Thanks
>
>      Luis
>
> ------------------------------------
>
> Gwenaël Guillard wrote:
>
> > Hi,
> >
> > I try to use a file reader. I wrote, as in the GaussianFilter example
> >
> >        VolumeReaderType::Pointer Reader = VolumeReaderType::New();
> >        itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New();
> >        Reader->SetImageIO( metaImageIO );
> >        Reader->SetFileName( filename );
> >
> > But when I want to get
> > Reader->GetOutput()->GetLargestPossibleRegion()->GetSize(), for example,
> > it gives me 0,0,0, which is not
> > the dimensions of my data. These data are .rwa and I use a mhd file. I
> > use the mhd file with the GaussianFilter example and it was
> > ok.
> >
> > Thank you,
> >
> > Gwenael
> >
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-users
> >
> >

--
-----------------------------------------------------------
Gwenael Guillard
Doctorant
Departement Image et Traitement de l'Information (ITI)
LAboratoire  de Traitement de l'Information Medicale (LATIM) - INSERM ERM 0102
ENST Bretagne
Technopole Brest Iroise
BP 832 - 29285 Brest Cedex
Tel : 02 29 00 13 01
email : gwenael.guillard@enst-bretagne.fr, g.guillard@ieee.org



--------------9E960C90998B2C497DE28F58
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi,
<p>Thank you for your answer. You are right, the Update( ) is after but
the problem is still there. It seems that the Update( ) method send an
exception
<br>The code is
<br>&nbsp;
<p>In the main method
<br>&nbsp;
<blockquote>
<blockquote>&nbsp; try
<br>&nbsp; {
<br>&nbsp;&nbsp;&nbsp; Load( filename );
<br>&nbsp; }
<br>&nbsp; catch( ... )
<br>&nbsp; {
<br>&nbsp;&nbsp;&nbsp; fl_message("Problem reading the files");
<br>&nbsp; }</blockquote>
</blockquote>

<p><br>In Load( ) Method
<br>&nbsp;
<blockquote>
<blockquote>&nbsp; VolumeReaderType::Pointer Reader = VolumeReaderType::New();
<br>&nbsp;
<br>&nbsp; itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New();
<br>&nbsp; Reader->SetImageIO( metaImageIO );
<p>&nbsp; Reader->SetFileName( filename );
<br>&nbsp; printf("avant GetOutput\n");
<br>&nbsp;
<br>&nbsp; PixelType width, height;
<br>&nbsp; width = Reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0];
<br>&nbsp; height = Reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1];
<p>&nbsp; Reader->Update();
<br>&nbsp; printf("after Update()\n");</blockquote>
</blockquote>

<p><br>It never writes "after Update()" but it shows the alert message.
I'm able to get width and height&nbsp; (0 for both because the update is
not done yet as you said). So the problem is when the update is called.
I try my data on gaussianFilter and there wasn't any problem.
<p>Gwenael
<br>&nbsp;
<br>&nbsp;
<p>Luis Ibanez a &eacute;crit :
<blockquote TYPE=CITE>Hi Gwenael,
<p>Did you call "Update()" on the reader ?
<p>The output of filters is not valid until
<br>an Update() call has been issued on them.
<br>Please make sure that you call "Update()"
<br>before calling "GetOutput()" on a reader.
<p>You will find many examples of Read/Write
<br>operations in the Insight/Examples directory.
<p>In particular on the directories:
<p>&nbsp;&nbsp;&nbsp; Examples/Filtering
<br>&nbsp;&nbsp;&nbsp; Examples/IO
<p>You may also want to take a look at the
<br>SoftwareGuide.pdf document:
<br><a href="http://public.kitware.com/Insight/Web/HTML/SoftwareGuide.pdf">http://public.kitware.com/Insight/Web/HTML/SoftwareGuide.pdf</a>
<p>In particular the chapters:
<p>- "Filtering"
<br>- "Reading and Writting Images"
<p>Please let us know if you have further questions,
<p>&nbsp;&nbsp; Thanks
<p>&nbsp;&nbsp;&nbsp;&nbsp; Luis
<p>------------------------------------
<p>Gwena&euml;l Guillard wrote:
<p>> Hi,
<br>>
<br>> I try to use a file reader. I wrote, as in the GaussianFilter example
<br>>
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VolumeReaderType::Pointer
Reader = VolumeReaderType::New();
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itk::MetaImageIO::Pointer
metaImageIO = itk::MetaImageIO::New();
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Reader->SetImageIO( metaImageIO
);
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Reader->SetFileName( filename
);
<br>>
<br>> But when I want to get
<br>> Reader->GetOutput()->GetLargestPossibleRegion()->GetSize(), for example,
<br>> it gives me 0,0,0, which is not
<br>> the dimensions of my data. These data are .rwa and I use a mhd file.
I
<br>> use the mhd file with the GaussianFilter example and it was
<br>> ok.
<br>>
<br>> Thank you,
<br>>
<br>> Gwenael
<br>>
<br>>
<br>> _______________________________________________
<br>> Insight-users mailing list
<br>> Insight-users@public.kitware.com
<br>> <a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a>
<br>>
<br>></blockquote>

<pre>--&nbsp;
-----------------------------------------------------------
Gwenael Guillard
Doctorant
Departement Image et Traitement de l'Information (ITI)
LAboratoire&nbsp; de Traitement de l'Information Medicale (LATIM) - INSERM ERM 0102
ENST Bretagne
Technopole Brest Iroise
BP 832 - 29285 Brest Cedex
Tel : 02 29 00 13 01
email : gwenael.guillard@enst-bretagne.fr, g.guillard@ieee.org</pre>
&nbsp;</html>

--------------9E960C90998B2C497DE28F58--