[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> </DIV>
<DIV><FONT face=3DArial size=3D2>I have written 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> </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> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is my program:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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
<iostream></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>#include=20
<itkImage.h><BR>#include <itkImageFileReader.h><BR>#include=20
<fltkImageViewer.h></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>#include =
<FL/Fl.H><BR>#include=20
<FL/fl_file_chooser.H></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </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> </DIV>
<DIV><FONT color=3D#ff0000> typedef fltk::ImageViewer< float, =
unsigned=20
char > ImageViewerType;<BR> =
typedef=20
float &n=
bsp; &nb=
sp; &nbs=
p; =20
&=
nbsp; =20
PixelType;<BR> typedef itk::Image<PixelType,=20
3> &n=
bsp; &nb=
sp; =20
ImageType; <BR> typedef itk::ImageFileReader< ImageType=20
> &nb=
sp; =20
VolumeReaderType;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> std::cout << "Loading =
File: "=20
<< filename << std::endl;<BR> =20
VolumeReaderType::Pointer m_Reader =3D=20
VolumeReaderType::New();<BR> m_Reader->SetFileName( =
filename=20
);<BR> m_Reader->Update();</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> ImageViewerType =
*m_AnyViewer=3D new=20
ImageViewerType;<BR> m_AnyViewer->SetImage(=20
m_Reader->GetOutput() );<BR> =
m_AnyViewer->Show();</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> std::cout << "Image [ " =
<<=20
filename << " ] Showed ..." << std::endl;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000>}</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT=20
color=3D#ff0000>/////////////////////////////////////////////////////////=
///<BR>int=20
main(int argc, char **argv)<BR>{<BR> char=20
*fName;<BR> <BR> if(argc =3D=3D 1)<BR> =20
{<BR> fName =3D fl_file_chooser("Pick a =
MetaImage=20
file", "*.mh*", ".");<BR> if(fName =3D=3D =
NULL ||=20
strlen(fName)<1)<BR> =20
{<BR> return=20
0;<BR> }<BR> } else =
if(argv[1][0] !=3D=20
'-') {<BR> fName =3D =
argv[argc-1];<BR> }=20
</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> LoadShowImage(fName);<BR> =20
<BR> return 1;<BR>}<BR></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial=20
size=3D2>->8<------------->8<------------->8<----------=
--->8<------------->8<------------->8<-<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> =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--