[Insight-users] ITK + QT

Luis Ibanez luis.ibanez at kitware.com
Thu May 8 10:38:53 EDT 2008



Hi Miroslav,


We don't have an example on conversion of ITK images to Qtimage,
but the essential elements should be the following:



    typedef itk::Image< unsigned char, 2 >   ImageType;

    typedef itk::ImageFileReader< ImageType > ReaderType;

    ReaderType::Pointer reader = ReaderType::New();

    reader->SetFileName("myDicomslice");

    try
      {
      reader->Update();
      }
    catch( itk::ExcetptionObject & excp )
      {
      std::cerr << excp << std::endl;
      return EXIT_FAILURE;
      }

    ImageType::ConstPointer image = reader->GetOutput();

    //
    //   Build a QImage
    //
    //   http://doc.trolltech.com/2.3/qimage.html#6ed060
    //
    const unsigned char * pixelBuffer = image->GetBufferPointer();
    const int width  = image->GetBufferedRegion().GetSize()[0];
    const int height = image->GetBufferedRegion().GetSize()[1];
    QRgb colorTable = NULL;
    const int numColors = 256;
    Endian bitOrder = IgnoreEndian;


    QImage myImage( pixelBuffer, width, height,
                    colorTable, numColors, bitOrder);


    Note that this will


  Please give it a try and let us know if you run into any problems.


  BTW it will be great if you contribute this as a example on
      how to use ITK+Qt, by posting it as a short technical report
      to the Insight Journal:
      http://www.insight-journal.org/InsightJournalManager/index.php



    Regards,


       Luis


-------------------------
Miroslav Levkovec wrote:
> Thanks for replies and QT-ITK examples,
> but i still have a problem. I dont know how to transform DICOM(2 & 
> 3dimensions) images to Qt image. Maybe You have some ideas or  know 
> where I could find somthing about this?
> 
> Best Regards
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list