Draw dicom raw data in qt - c++

I'm trying to develop a tool to visualize dicom images
I'm using itk library but i have some problem drawing the data
I'm using gdcm library provided by itk library as a third party lib.
I'm reading the image correctly i retrieved the tags ... but when i retrieve the pixels data using
unsigned short buffer* = ImageFileReader<Image<unsigned short,2>>->GetOutput()->getBufferPointer();
and i put it in QPixmap or QImage i tried both,Qpixelmap when i do loadData i get false as a return value and using QImage, the app crashes !
Any help ? thank you

Look at this example, http://gdcm.sourceforge.net/html/ConvertToQImage_8cxx-example.html
Just use gdcm to read the image and convert it to qimage.
Keep in mind that dicom images are not an image format that qt can draw, you need a conversion step.

Related

Send img VTK for ITK

In VTK and ITK it is possible to pass images between them.
But, it's only possible to send image from ITK to VTK using
itk::ImageToVTKImageFilter.
Is it possible to send an image from vtk to itk ?
There is a filter, itk::ImportImageFilter, that takes the image buffer (that array returned by vtkImageData.GetScalarPointer()) and image properties like size, origin and spacing, and creates an itk::Image.
https://itk.org/Wiki/ITK/Examples/IO/ImportImageFilter shows how to import a C array to ITK as an image. Importing a vtkImageData is very similar.
Basically you will get the vtkImageData's spacing, origin, dimensions and use it as an input to the itk filter mentioned above. Pay attention to data type: if the vtkImageData's scalars are shorts the itk::image should be an itk::Image (3 if it's a 3d image, 2 if it's a 2d image).
Of course, syncronization between the vtk part of your pipeline and the itk part of your pipeline will have to be done manually, unless you can garantee that the imageData from which you get the pointer is always the same.
Here is an example :
http://itk.org/ITKExamples/src/Bridge/VtkGlue/ConvertvtkImageDataToAnitkImage/Documentation.html
HTH,
Simon

Convert 32bpp image to 8bpp in Leptonica

I've recently started working with leptonica Image processing API. But every API function seems to be taking input image of 8bpp and my images are 32bpp (or could be anything else). So is there any function in Leptonica which could convert my image from 32bpp to 8bpp. I've searched but no luck.
Is it so that there is no function to do that or we have to feed leptonica only 8bpp image to process it furthur (Such as binarization)?
Or do we have to convert the image from any other 3rd party tool then feed it to leptonica.
I am new to image processing and leptonica. Thanks in advance for your suggestions.
There are several methods, e.g., pixConvertRGBToGray, pixThresholdToBinary, etc. Check its documentation for usage.
http://tpgit.github.io/UnOfficialLeptDocs/leptonica/
http://tpgit.github.io/UnOfficialLeptDocs/leptonica/functions.html

Cimg and itk image

I have a Cimg image and I want to use it with ITK (for registration). How can I create a ITK image from this Cimg image. Also can I want to create an OpenCV image from a ITK image? So can I use these libraries together?
Thanks for helping.
The ITK class OpenCVImageBridge will be useful in converting ITK images to OpenCV images:
http://www.itk.org/Doxygen/html/classitk_1_1OpenCVImageBridge.html
Unfortunately I'm not familiar with Cool Image, and so cannot be helpful for the first part of the question. ITK can read a large number of image types--png, dcm, mha, tiff, bmp, etc--your best bet is likely to look down the list of image types that Cimg can write, and find one that ITK can read.

Problems rendering an image in gtk

I'm programming an application in c++ with a GUI in GTK3 that will show the images obtained from a genicam camera. I've got the official API of the camera that deals with it and extract returns an unsigned char* to the buffer where the image is contained.
The problem comes when I try to convert the image to a GTK format to render it in the GUI. I've tried with cairo and pixbuf, but I've problems in both of them, as the image is in MONO8 format, and pixbuf only deals with RGB. Cairo can deal with 8bit images, but only if they have an alpha channel, which is not the case.
Does someone know a way to approach this issue?
Thanks in advance

Imaging library to display yuv data in C++ and Qt

I was wondering is there any C++ imaging libraries so that I can take a yuv file and display it, I will be able to pass the resolution of the file and Ycbcr info(usually at 4:2:2) I need this to turn the yuv into jpegs if possible or to display it in rgb mode to be built on a QPixmap. If anyone could point me in the right direction I'd be most grateful.
I just looked around, did you tried the following ?
http://code.google.com/p/yuvtoolkit
http://code.google.com/p/yuvplayer