[Insight-users] Using ImageReadCastWrite Example

Luis Ibanez luis.ibanez at kitware.com
Tue Jun 29 23:59:15 EDT 2004


Hi Misha,

1) You may find interesting to play with color maps
    in VolView and ParaView they can be downloaded
    respectively from:

     http://www.kitware.com/products/volview.html

     http://www.paraview.org


2) Regarding the file format, the best options for
    you are:

     - Analyze
     - MetaImage
     - GIPL
     - VTK

    All of them can be read with the ImageViewer
    application in InsightApplications.



Regards,



    Luis


------------------
Misha Nizker wrote:

> Ah ha!  Thank you very much.
> 
> Yup the image is a CT scan and I did use the color scheme feature.  I was
> suspecting that it was an internal color-changing feature, but had to be
> sure.  Since this particular scheme was called "GE_Color", I figured that it
> was possible that that was the way it was supposed to come out.  I'll look
> into VTK.
> 
> As for the second image, it actually does the shift when using the PNG
> format too.  Is there another one I could try that wouldn't suffer from
> these side-effects?
> 
> Thank you,
> 
> Misha
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
> Sent: Tuesday, June 29, 2004 5:54 PM
> To: Misha Nizker
> Cc: insight-users at itk.org
> Subject: Re: [Insight-users] Using ImageReadCastWrite Example
> 
> 
> Hi Misha,
> 
> 
> Thanks for posting the images, they help a lot.
> 
> 
> There are two separate issues here:
> 
> 
> 1) Your GE image looks like a CT scan. Is it a CT scan ?
> 
>     If so, the reason why you see a color image in MRICro
>     is because your are enabling artificial coloring of the
>     dataset.
> 
>      You probably visited in MRICro the menu option:
> 
>               Overlay ---->>> Color Scheme
> 
>     which will simply enable a color map into your
>     data set.
> 
>     This is a visualization issue, not something related
>     to image analysis per se. If you *really* want to reproduce
>     such coloring effect you should incorporate VTK visualization
>     filter into your application and get familiar with the use
>     of color maps for visualization.
> 
>     You could also implement a colormap in ITK by using the
>     FunctorImageFilter.
> 
> 
> 2) The second image that you posted, just shows the
>     known bug in the JPEG writer when you feed it with
>     16 bits images.  Please use another file format.
>     Probably Analyze is the best option since you will
>     be able to read it in other programs including VolView,
>     and MRICro.
> 
> 
> Please let us know if you have further questions,
> 
> 
>     Thanks
> 
> 
>        Luis
> 
> 
> --------------------------
> 
> Misha Nizker wrote:
> 
> 
>>Hello, 
>>
>>Thanks for the help, the .jpg conversions work now.  However, there is
> 
> still
> 
>>a problem when using the GE5ImageIO filter.  For some reason, the GE
> 
> images
> 
>>still get rendered into black and white.  They are also slightly shifted
> 
> to
> 
>>the side.  
>>
>>I am currently using RGBPixel< unsigned char > which seems to be working
>>fine for .jpg.  I tried unsigned short to increase the bit depth (to
>>16-bit), but the fileReader complained that it wasn't configured to use
> 
> that
> 
>>variable.  
>>
>>Any idea on why the image is refusing to be rendered as colour?  I have
>>hosted the input (as seen by MRIcro) at http://24.83.47.77/MRI/input.jpg
> 
> and
> 
>>the output (converted into .png and took a screenshot, same result when
>>converting to .jpg) at http://24.83.47.77/MRI/output.jpg.  
>>
>>
>>Thank you,
>>
>>Misha
>>
>>-----Original Message-----
>>From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
>>Sent: Monday, June 28, 2004 8:35 PM
>>To: EUGINE NIZKER
>>Cc: insight-users at itk.org
>>Subject: Re: [Insight-users] Using ImageReadCastWrite Example
>>
>>
>>Hi Eugine,
>>
>>If you want the image to be read and written in color
>>you must use a RGBPixel<> type as the image pixel type.
>>
>>Please look at the examples:
>>
>>    Insight/Examples/IO/
>>               RGBImageReadWrite.cxx
>>               RGBImageSeriesReadWrite.cxx
>>
>>
>>Regards,
>>
>>
>>    Luis
>>
>>
>>-----------------------
>>EUGINE NIZKER wrote:
>>
>>
>>
>>>Hello,
>>>
>>>I have recently downloaded and installed ITK version 1.6 and am trying to
>>
>>use it for doing a GE5 -> PNG conversion.  I gather that the
>>ImageReadCastWrite code contains the proper info for that, and can
> 
> actually
> 
>>get the image to show, but the problem is that it's in greyscale (almost
>>black and white) instead of being in full color like the original image
>>(seen by MRIcro).  
>>
>>
>>>I tested this with other conversions like .bmp to .jpg or even .jpg to
>>
>>.jpg and the output always appears black and white for whatever reason...
> 
> I
> 
>>am currently using the RescaleIntensityImageFilter between the input and
>>output since this is the one that was used in the example.  Could this be
>>the problem?  I tried changing the maximum and minimum intensity settings
> 
> on
> 
>>the filter, but that didn't seem to affect the output image at all.  
>>
>>
>>>Can anyone please help?  
>>>
>>>
>>>
>>>Here is my code just in case it's helpful:
>>>
>>>
>>
>>
> /*=========================================================================
> 
>>> Program:   Insight Segmentation & Registration Toolkit
>>> Module:    $RCSfile: ImageReadCastWrite.cxx,v $
>>> Language:  C++
>>> Date:      $Date: 2003/12/17 12:55:28 $
>>> Version:   $Revision: 1.7 $
>>>
>>> Copyright (c) Insight Software Consortium. All rights reserved.
>>> See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for
>>
>>details.
>>
>>
>>>    This software is distributed WITHOUT ANY WARRANTY; without even 
>>>    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
>>>    PURPOSE.  See the above copyright notices for more information.
>>>
>>>
>>
>>
> =========================================================================*/
> 
>>>#include "itkImageFileReader.h"
>>>#include "itkImageFileWriter.h"
>>>#include "itkRescaleIntensityImageFilter.h"
>>>
>>>#include "itkCropImageFilter.h"
>>>
>>>
>>>#include "itkImage.h"
>>>
>>>
>>>int main( int argc, char ** argv )
>>>{
>>> if( argc < 3 )
>>>   {
>>>   std::cerr << "Usage: " << std::endl;
>>>   std::cerr << argv[0] << " inputImageFile  outputImageFile " <<
>>
>>std::endl;
>>
>>
>>>   return -1;
>>>   }
>>>
>>>
>>> typedef unsigned char       InputPixelType;
>>> typedef unsigned char       OutputPixelType;
>>> const   unsigned int        Dimension = 2;
>>>
>>> typedef itk::Image< InputPixelType,  Dimension >    InputImageType;
>>> typedef itk::Image< OutputPixelType, Dimension >    OutputImageType;
>>>
>>> typedef itk::ImageFileReader< InputImageType  >  ReaderType;
>>> typedef itk::ImageFileWriter< OutputImageType >  WriterType;
>>>
>>>
>>> typedef itk::RescaleIntensityImageFilter< 
>>>                                 InputImageType, 
>>>                                 OutputImageType >    FilterType;
>>>
>>> FilterType::Pointer filter = FilterType::New();
>>> filter->SetOutputMinimum(   0 );
>>> filter->SetOutputMaximum( 255 );
>>>
>>> ReaderType::Pointer reader = ReaderType::New();
>>> WriterType::Pointer writer = WriterType::New();
>>>
>>> filter->SetInput( reader->GetOutput() );
>>> writer->SetInput( filter->GetOutput() );
>>>
>>>
>>> const char * inputFilename  = argv[1];
>>> const char * outputFilename = argv[2];
>>>
>>> reader->SetFileName( inputFilename  );
>>> writer->SetFileName( outputFilename );
>>>
>>>
>>> try 
>>>   { 
>>>   writer->Update(); 
>>>   } 
>>> catch( itk::ExceptionObject & err ) 
>>>   { 
>>>   std::cout << "ExceptionObject caught !" << std::endl; 
>>>   std::cout << err << std::endl; 
>>>   return -1;
>>>   } 
>>>
>>>
>>> return 0;
>>>}
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>
>>_______________________________________________
>>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