[Insight-users] fltk viewer

Zein Salah salah@gris.uni-tuebingen.de
Wed, 18 Sep 2002 12:34:23 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_008A_01C25F0F.B7FD8AB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello friends,

I have written a very simple program that just reads a meta file and =
displays it using the fltkimage viewer.

the program reads the file correctly, displays it. BUT I can not see the =
displayed files because the fltk viewer panel ends execution very fast, =
it just flashes once and then disappears.

Do anybody have an idea, where the problem is.=20

Here is my program:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
#include <iostream>

#include <itkImage.h>
#include <itkImageFileReader.h>
#include <fltkImageViewer.h>

#include <FL/Fl.H>
#include <FL/fl_file_chooser.H>


///////////////////////////////////////////////////////////
void LoadShowImage(char *filename)
{

  typedef fltk::ImageViewer< float, unsigned char >      =
ImageViewerType;
  typedef float                                                          =
 PixelType;
  typedef itk::Image<PixelType, 3>                             =
ImageType;=20
  typedef itk::ImageFileReader< ImageType >              =
VolumeReaderType;

   std::cout << "Loading File: " << filename << std::endl;
   VolumeReaderType::Pointer   m_Reader =3D VolumeReaderType::New();
   m_Reader->SetFileName( filename );
   m_Reader->Update();

   ImageViewerType  *m_AnyViewer=3D new ImageViewerType;
   m_AnyViewer->SetImage( m_Reader->GetOutput() );
   m_AnyViewer->Show();

   std::cout << "Image [ " << filename << " ] Showed ..." << std::endl;

}

////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
   char *fName;
=20
   if(argc =3D=3D 1)
   {
      fName =3D fl_file_chooser("Pick a MetaImage file", "*.mh*", ".");
      if(fName =3D=3D NULL || strlen(fName)<1)
      {
         return 0;
      }
   } else if(argv[1][0] !=3D '-') {
      fName =3D argv[argc-1];
   }=20

   LoadShowImage(fName);
 =20
   return 1;
}




->8<------------->8<------------->8<------------->8<------------->8<-----=
-------->8<-
Zein I. Salah=20
Universit=E4t T=FCbingen, WSI-GRIS=20
Sand 14=20
72076 T=FCbingen=20
Email: salah@gris.uni-tuebingen.de  / zeinsalah@hotmail.com
Tel.: (07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)=20

------=_NextPart_000_008A_01C25F0F.B7FD8AB0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2715.400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello friends,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have written&nbsp;a very simple =
program that just=20
reads a meta file and displays it using the fltkimage =
viewer.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the program reads the file correctly, =
displays it.=20
BUT I can not see the displayed files because the fltk viewer panel ends =

execution very fast, it just flashes once and then =
disappears.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Do anybody have an idea, where the =
problem is.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here is my program:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#ff0000=20
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D*/<BR>#include=20
&lt;iostream&gt;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>#include=20
&lt;itkImage.h&gt;<BR>#include &lt;itkImageFileReader.h&gt;<BR>#include=20
&lt;fltkImageViewer.h&gt;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>#include =
&lt;FL/Fl.H&gt;<BR>#include=20
&lt;FL/fl_file_chooser.H&gt;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV><FONT face=3DArial =
size=3D2>
<DIV><BR><FONT=20
color=3D#ff0000>/////////////////////////////////////////////////////////=
//<BR>void=20
LoadShowImage(char *filename)<BR>{</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>&nbsp; typedef fltk::ImageViewer&lt; float, =
unsigned=20
char &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageViewerType;<BR>&nbsp; =
typedef=20
float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;=20
PixelType;<BR>&nbsp; typedef itk::Image&lt;PixelType,=20
3&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;=20
&nbsp; ImageType; <BR>&nbsp; typedef itk::ImageFileReader&lt; ImageType=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
VolumeReaderType;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>&nbsp;&nbsp; std::cout &lt;&lt; "Loading =
File: "=20
&lt;&lt; filename &lt;&lt; std::endl;<BR>&nbsp;&nbsp;=20
VolumeReaderType::Pointer&nbsp;&nbsp; m_Reader =3D=20
VolumeReaderType::New();<BR>&nbsp;&nbsp; m_Reader-&gt;SetFileName( =
filename=20
);<BR>&nbsp;&nbsp; m_Reader-&gt;Update();</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>&nbsp;&nbsp; ImageViewerType&nbsp; =
*m_AnyViewer=3D new=20
ImageViewerType;<BR>&nbsp;&nbsp; m_AnyViewer-&gt;SetImage(=20
m_Reader-&gt;GetOutput() );<BR>&nbsp;&nbsp; =
m_AnyViewer-&gt;Show();</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>&nbsp;&nbsp; std::cout &lt;&lt; "Image [ " =
&lt;&lt;=20
filename &lt;&lt; " ] Showed ..." &lt;&lt; std::endl;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>}</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT=20
color=3D#ff0000>/////////////////////////////////////////////////////////=
///<BR>int=20
main(int argc, char **argv)<BR>{<BR>&nbsp;&nbsp; char=20
*fName;<BR>&nbsp;<BR>&nbsp;&nbsp; if(argc =3D=3D 1)<BR>&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fName =3D fl_file_chooser("Pick a =
MetaImage=20
file", "*.mh*", ".");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(fName =3D=3D =
NULL ||=20
strlen(fName)&lt;1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return=20
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp; } else =
if(argv[1][0] !=3D=20
'-') {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fName =3D =
argv[argc-1];<BR>&nbsp;&nbsp; }=20
</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#ff0000>&nbsp;&nbsp; LoadShowImage(fName);<BR>&nbsp;=20
<BR>&nbsp;&nbsp; return 1;<BR>}<BR></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>-&gt;8&lt;-------------&gt;8&lt;-------------&gt;8&lt;----------=
---&gt;8&lt;-------------&gt;8&lt;-------------&gt;8&lt;-<BR>Zein=20
I. Salah <BR>Universit=E4t T=FCbingen, WSI-GRIS <BR>Sand 14 <BR>72076 =
T=FCbingen=20
<BR>Email: <A=20
href=3D"mailto:salah@gris.uni-tuebingen.de">salah@gris.uni-tuebingen.de</=
A>&nbsp;=20
/ <A =
href=3D"mailto:zeinsalah@hotmail.com">zeinsalah@hotmail.com</A><BR>Tel.: =

(07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat) =
</FONT></DIV></BODY></HTML>

------=_NextPart_000_008A_01C25F0F.B7FD8AB0--