Hey everyone I'm sorry for such a strange question I'm very new to C++ and DCMTK in general, and now I'm faced with a strange problem.
I wanted to write a small application that reads in a filename of a DICOM image and returns its width and height (in pixels). So I used this piece of code:
-----------------------------------------------------------------------------
//Load DICOM image
const char* filename = "C:\\home\\dicom\\db\\ACME_STORE\\ct.001";
DicomImage *m_originalImage = new DicomImage(filename);
//Extract information
const char* status = DicomImage::getString(m_originalImage->getStatus());
int width = m_originalImage->getWidth();
int height = m_originalImage->getHeight();
//Print information
cout<<status<<endl;
cout<<"Width: "<<width<<endl;
cout<<"Height: "<<height<<endl;
----------------------------------------------------------------------------------
And strange it worked at first but all of a sudden it stopped working, and now it says that the width and heigth are both 0. I traced the problem all the way to the DiImage class, and when I cout<<Columns it still prints 0. I believe the image is fine- I've downloaded it a few times again and for some reason the Representative Frame info prints out fine.
And it gets stranger, because when I debug, it shows that Columns = 512 but when I cout it the command prompt shows 0. Then, if I make any change to the code and run debug again, Columns = 0. Only if I rebuild it does Columns go back to 512, even though the output is still 0. This is such a bizarre problem, and my friend says it may be due to strange library linkage problems. I would really appreciate any help. Thanks so much!
________
Bmw m2b15
Returning rows and columns as 0?
Moderator: Moderator Team
Returning rows and columns as 0?
Last edited by zanguzen on Mon, 2011-02-14, 02:16, edited 1 time in total.
-
- OFFIS DICOM Team
- Posts: 1459
- Joined: Tue, 2004-11-02, 17:22
- Location: Oldenburg, Germany
- Contact:
In my experience variable values that "suddenly" change are usually an indication of either stack corruption or heap corruption, typically caused by some piece of code overwriting beyond the limits of a stack frame or heap object. Such bugs are typically hard to find - tools such as Valgrind might be of help.
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest