[Insight-users] Re: FW: Help with reading raw image in ITK
Luis Ibanez
luis.ibanez at kitware.com
Mon Apr 23 10:57:46 EDT 2007
Hi Mitali,
My mistake,
The correct links is to the ImageViewer binary is:
http://public.kitware.com/pub/itk/InsightApplicationsBin/
The files in this directory are the binary executables of
some of the applications in InsightApplications. You don't
need the source code of InsightApplications in order to use
these executables. In fact, the whole point of distributing
the binaries is that users would be able to use them without
having to download the source code of InsightApplications
and without having to build the projects.
As I described in my email, I was able to see your image
in the ImageViewer, and it appeared normal.
Please give it a try to this viewer and let us know
what you find,
Thanks
Luis
--------------------------
More, Mitali J *HS wrote:
> Luis,
>
> Thank you for your response. I am not able to access the link you sent
> me to download the Image Viewer application.
> http://public.kitware.com/ftp/pub/itk/InsightApplicationsBin
>
> Is there a problem with the page?
>
> Also, this looks like some Application that has been written in ITK. Do
> I need to download and build InsightApplications to use the Image
> Viewer? Right now, I do not have it built.
>
> If I understand this correctly, ITK is able to read my images correctly.
> There is a problem with MRICro opening them. So, I should be able to
> display my images correctly using Image Viewer. Is that correct?
>
> Thanks again for taking the time to help me.
>
> Mitali
>
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
> Sent: Saturday, March 31, 2007 12:12 PM
> To: More, Mitali J *HS
> Cc: Insight Users
> Subject: Re: FW: Help with reading raw image in ITK
>
>
>
> Hi Mitali,
>
> Thanks for sending the image.
>
> I can read your test_2.hdr + test_2.img image without problem
> using the ImageViewer application.
>
> Also, using your description of the image, I also wrote the
> MetaImage header for the raw file, and was able to load it
> into the ImageViewer application. The MetaImage header is
> attached to this email, please put it in the same directory
> where you have the file test_2.img.
>
>
> You can get this application from:
>
> http://public.kitware.com/ftp/pub/itk/InsightApplicationsBin
>
> /ImageViewer.exe
>
> If your system is not too recent, you may need to copy also
> the DLL files:
>
> msvcp71.dll
> msvcp71d.dll
> msvcr71.dll
> msvcr71d.dll
>
> Note that you must put the DLLs in the *same* directory where
> you put the ImageViewer application.
>
>
> I was able to see your image by doing :
>
>
> ImageViewer test_2.hdr
>
> and
>
> ImageViewer test_2.img
>
>
> Please give it a try to this applications and let us know
> how it works in your system.
>
>
> BTW, looking back at your code for reading the binary image,
> you were indicating that the binary file had a header of
> 512 bytes. This is incorrect. The .img file does not have
> any header. The header information is in the .hdr file.
>
>
> In general, you should not use the RawImageIO class.
> It is much better to simply write the MetaImage header
> for the raw file, and then use the ImageFileReader.
>
>
>
>
> Regards,
>
>
> Luis
>
>
>
> --------------------------
> More, Mitali J *HS wrote:
>
>>Luis,
>>
>>The image has been uploaded successfully. This is the original 5518 x
>>3677 image. I read it using ITK and write as img. I was not able to
>
> read
>
>>using MRICro (not enough memory). ImageJ could open the file. But it
>>looked messed up.
>>
>>Thanx for helping me out,
>>
>>Mitali
>>
>>
>>
>>>>>*From:* More, Mitali J *HS
>>>>>*Sent:* Tuesday, March 27, 2007 5:14 PM
>>>>>*To:* 'insight-users at itk.org'
>>>>>*Subject:* Help with reading raw image in ITK
>>>>>
>>>>>
>>>>>
>>>>>Hi All,
>>>>>
>>>>>
>>>>>
>>>>>I am having trouble reading a raw image using ITK's RawImageIO
>>
>>filter.
>>
>>
>>>>>These are 2D images, unsigned short, 5518 x 3677, 512 header bytes,
>>>>
>>>>liitle-endian. I have provided all this information in my code. I am
>>>>attaching my code snippet here:
>>>>
>>>>
>>>>
>>>>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
>>>>----
>>>>
>>>>
>>>>
>>>>
>>>>>#include <iostream>
>>>>>
>>>>>#include "itkImageFileReader.h"
>>>>>
>>>>>#include "itkRawImageIO.h"
>>>>>
>>>>>#include "itkImageFileWriter.h"
>>>>>
>>>>>#include "itkImageIOBase.h"
>>>>>
>>>>>#include "itkImage.h"
>>>>>
>>>>>
>>>>>
>>>>>int main( int argc, char * argv[] )
>>>>>
>>>>>
>>>>>
>>>>>{
>>>>>
>>>>>typedef unsigned short PixelType;
>>>>>
>>>>>typedef itk::Image < PixelType, 2 > ImageType;
>>>>>
>>>>>typedef itk::RawImageIO < PixelType,2 > ImageIOType;
>>>>>
>>>>>typedef itk::ImageFileReader< ImageType > ReaderType;
>>>>>
>>>>>typedef itk::ImageFileWriter< ImageType > WriterType;
>>>>>
>>>>>
>>>>>
>>>>>ImageIOType::Pointer rawImageIO = ImageIOType::New();
>>>>>
>>>>>
>>>>>
>>>>>rawImageIO->SetFileName( argv[1] );
>>>>>
>>>>>rawImageIO->SetFileTypeToBinary();
>>>>>
>>>>>rawImageIO->SetHeaderSize(512);
>>>>>
>>>>>rawImageIO->SetFileDimensionality(2);
>>>>>
>>>>>
>>>>>
>>>>>rawImageIO->SetOrigin( 0, 0.0 ); // origin in millimeters
>>>>>
>>>>>rawImageIO->SetOrigin( 1, 0.0 );
>>>>>
>>>>>
>>>>>
>>>>>rawImageIO->SetDimensions( 0, 5518 ); // size in pixels
>>>>>
>>>>>rawImageIO->SetDimensions( 1, 3677 );
>>>>>
>>>>>
>>>>>
>>>>>rawImageIO->SetSpacing( 0, 0.05 ); // spacing in millimeters
>>>>>
>>>>>rawImageIO->SetSpacing( 1, 0.05 );
>>>>>
>>>>>
>>>>>
>>>>>rawImageIO->SetByteOrderToLittleEndian();
>>>>>
>>>>>rawImageIO->SetPixelType(itk::ImageIOBase::SCALAR);
>>>>>
>>>>>rawImageIO->SetNumberOfComponents(1);
>>>>>
>>>>>
>>>>>
>>>>>ReaderType::Pointer reader = ReaderType::New();
>>>>>
>>>>>reader->SetImageIO( rawImageIO );
>>>>>
>>>>>reader->SetFileName( argv[1] );
>>>>>
>>>>>
>>>>>
>>>>>WriterType::Pointer writer = WriterType::New();
>>>>>
>>>>>writer->SetFileName(argv[2]);
>>>>>
>>>>>writer->SetInput(reader->GetOutput());
>>>>>
>>>>>
>>>>>
>>>>>return EXIT_SUCCESS;
>>>>>
>>>>>}
>>>>>
>>>>>
>>>>
>>>>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
>>>>------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>>
>>>>>I am writing these images as .img and opening them using Image J.
>
> The
>
>>>>image looks jumbled and for some reason is read as 8 bit data. What
>
> am
>
>>>I
>>>
>>>
>>>
>>>>doing wrong?
>>>>
>>>>
>>>>
>>>>
>>>>>Thanks
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>
More information about the Insight-users
mailing list