[Insight-users] Reading Jpeg file
Wang, Liqin
Wang.Liqin at mayo.edu
Wed Oct 22 18:20:06 EDT 2008
Hi,All
I want to read the Jpeg file by using the following codes:
//++++++++++++++++++++++++++++++
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::JPEGImageIO ImageIOType;
// Software Guide : EndCodeSnippet
ImageIOType::Pointer jpegIO = ImageIOType::New();
ReaderType::Pointer reader = ReaderType::New();
const char * filename = argv[1];
reader->SetFileName( filename );
reader->SetImageIO( jpegIO );
reader->Update();
//+++++++++++++++++++++++++++
But I kept getting the exception in the following function:
void JPEGImageIO::ReadImageInformation()
{
m_Spacing[0] = 1.0; // We'll look for JPEG pixel size information
later,
m_Spacing[1] = 1.0; // but set the defaults now
m_Origin[0] = 0.0;
m_Origin[1] = 0.0;
// use this class so return will call close
JPEGFileWrapper JPEGfp(m_FileName.c_str(),"rb");
FILE* fp = JPEGfp.m_FilePointer;
if(!fp)
{
itkExceptionMacro("Error JPEGImageIO could not open file: "
<< this->GetFileName());
return;
}
.
.
.
Attached is a sample jpeg image used to test the program.
Thanks for helps.
Liqin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree1.jpg
Type: image/jpeg
Size: 4055 bytes
Desc: tree1.jpg
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081022/78e77cc9/attachment.jpg>
More information about the Insight-users
mailing list