[vtkusers] how to show vtk image in a QT widget
Wagner Sales
wsalles2003 at yahoo.com.br
Wed Apr 14 18:41:20 EDT 2004
Luke Hua wrote:
Well. I wasn't make that. But, if yoy needs some poins based on
selection and use it to pick, may be is more difficult, since ( that's
just like I understand, if I'm wrong, someone correct me ;) ) this
actions, on qt, are maked in a type like QPixmap or QImage. To make this
selection ( my use is to threshold ) I was implemented something like:
---> method portion
itk::ObjectFactoryBase::RegisterFactory(itk::DICOMImageIO2Factory::New());
itk::DICOMImageIO2::Pointer DICOMImage = itk::DICOMImageIO2::New();
itk::ImageFileReader<ImageDicomType>::Pointer fileReader =
itk::ImageFileReader<ImageDicomType>::New();
fileReader->SetFileName(filename);
fileReader->UpdateLargestPossibleRegion();
FilterType::Pointer filter = FilterType::New();
filter->SetOutputMinimum( 0 );
filter->SetOutputMaximum( 255 );
filter->SetInput(fileReader->GetOutput());
filter->Update();
imageItk = filter->GetOutput();
SizeType size = imageItk->GetLargestPossibleRegion().GetSize();
width = size[0];
height = size[1];
bpp = 8;
data = new unsigned short[width * height];
unsigned short *dest = data;
IteratorType
it(imageItk,imageItk->GetLargestPossibleRegion().GetSize());
it.GoToBegin();
while (!it.IsAtEnd()){
*dest++ = it.Get();
++it;
}
Whith that, I can write in every format. Then:
// before that you'll be needs to declare qimage with height and width.
this method can returns a qimage.
unsigned short *dest = data;
for (int i = 0; i < height; i++)
for (int j = 0; j < width; j++)
*dest++ = qGray(qimg.pixel(j, i))
then, you can paint this in a qwidget ( note: we don't have nothing in
vtk yet ) and capture the mouse events to return the coordinates. That's
more complicated if you use operations like zoom.
Well, may be that's not the best way, but just the first on my brain.
Sorry if can't help.
Cheers
> Thank you for your code! It is very helpful cause I want to use itk
> later as well.
>
> However, you are still using vtk render window. I don't know if I can
> manually draw line or contour on it. I want to implement some drawing
> function and region growth algorithm(picking) on the image. I'm not
> sure I can do it in render window.
>
> Thanks!
>
>
> Luke
>
> */Wagner Sales <wsalles2003 at yahoo.com.br>/* wrote:
>
> Luke Hua wrote:
>
> > I want to show vtk image for volume data in qt widget. I tried
> > vtkimageviewer. But it seems I can not draw and get correct
> coordinate
> > from the viewer. So I want to use qt's image widget instead.
> >
> > Should I use QCanvas or Qpixelmap directly? Where can I find
> example code?
> >
> > Thank you!
> >
> >
> > Luke
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------
> > Do you Yahoo!?
> > Yahoo! Tax Center - File online by April 15th
> >
>
> That's simple. Have more than one integration package to do this.
> I use
> the vtkQt1.7, you can download from
> http://wwwipr.ira.uka.de/~kuebler/vtkqt/.
> In atach, one example using ITK+QT+VTK.
>
> Regards
>
>
> > ATTACHMENT part 2 application/zip name=teste.zip
>
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> <http://taxes.yahoo.com/filing.html>
More information about the vtkusers
mailing list