Reading Image Data in Windows

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
rwdougla
Posts: 2
Joined: Wed, 2007-02-28, 15:58
Location: Ann Arbor, MI

Reading Image Data in Windows

#1 Post by rwdougla »

I am trying to load an entire series of CT images into a single array, for use and processing. The volume itself is just over 500 slices, each slice at 512x512 pixels. The way CT is stored, in seperate files on the system, I have to read in each file separately, and combine th eimage blocks into a single location.

My problem is that simply opening 500+ files and copying the image data out, even knowing the byte offset to the image block before opening the file, takes 30+ seconds to complete on my windows box. The volume itself becomes over 250 megs of data.

I am using fopen(fname, "rb") to open the files, and fseek() to go straight to the image data using a known image block offset, and then fread() to read the image block from each file.

I simply cannot think of a more efficient way to do this, and am hoping that there may be an expert here with some experience in fileio, that has had to face such challenges before.

Can anyone help?
Thanks!
- Robert Douglas

"If all you have is a hammer, everything begins to look like a nail."
- Proverb

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1459
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#2 Post by Marco Eichelberg »

Yes, the volume will be 250 MBytes (and for image processing tasks you can approximately multiply that by 4, so your machine should have > 1GB RAM).

The fopen, fseek, fread sequence will not work in DICOM because there is no fixed offset at which pixel data begins, so you will have to use a DICOM parser (such as DCMTK) to read the files, although the speed penalty should be very small.

Speeding up file I/O is not trivial. You might think of multiple threads opening (some) files in parallel, and a single thread doing the main work of reading bulk data (thus avoiding too many movements of the r/w head), or you might consider memory mapped I/O, overlapped I/O etc. if you really want to dig deeply into the proprietary Win32 API.

That said, 30 seconds for 250 MB off hard disk seems very slow to me. Modern hard disks should provide read performance exceeding 25 MBytes per second, so anything beyond 10 seconds is probably not optimal.

rwdougla
Posts: 2
Joined: Wed, 2007-02-28, 15:58
Location: Ann Arbor, MI

#3 Post by rwdougla »

Sorry for the late reply, thanks for the help, though!
- Robert Douglas

"If all you have is a hammer, everything begins to look like a nail."
- Proverb

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest