[Insight-users] Reading an image (64 bits program)

alex Dowson alexdowson at hotmail.com
Sun Jan 22 22:57:09 EST 2012



Hi

Your question is still not clear. But you said your image dimension is 300x255 means width is  300 and height is 255 right ?  then in your code for loop has i-value goes upto 1000 it is wrong.
you can’t go more then 300 in your case otherwise it will crash and also j value should be 255 not 300. 

Please check itk documentation software guide. You can also do with pixel operation image iterators . look at this examples for further understanding for iterators

http://www.itk.org/Wiki/ITK/Examples/Iterators/ImageRegionIteratorWithIndex 








alex


 

From: Ali Mouizina 
Sent: Sunday, January 22, 2012 8:39 PM
To: insight-users at itk.org 
Subject: [Insight-users] Reading an image (64 bits program)

Hi,

 

I started to build ITK with a 64 bits compiler and I’m having a problem when I read a jpg image. The dimension of my image is 300*225,  but when I try to read the values of my image I can go further than the image dimension.

 

typedef unsigned char PixelType;

typedef itk::Image<PixelType, 2> ImageType2D;

 

int main(){

 

       typedef itk::ImageFileReader< ImageType2D > ReaderType;

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

 

       const char *inputFilename="tour_b.jpg";

       reader->SetFileName(inputFilename);

       reader->Update();

 

       

       

       ImageType2D::Pointer image=reader->GetOutput();

 

       cout << sizeof(unsigned char) << endl; // -> It displays 1

 

       ImageType2D::IndexType pix;

 

       for (int i=0;i<1000;i++)

             for (int j=0;j<300;j++)

                    {

                           pix[0]=i;

                           pix[1]=j;

                           //pix[2]=k;

                           

                           image->GetPixel(pix);

 

                    }

}

 

Regards,

 

Ali



--------------------------------------------------------------------------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120123/94710140/attachment.htm>


More information about the Insight-users mailing list