Replies: 2 comments
-
There is no straightforward way to calculate the Pixel Data offset other than to iterate over the tags until the tag is found - basically read the tag header including the tag length, skip forward to the next tag (e.g. skip the tag length) and repeat. This is due to the structure of DICOM data and cannot be avoided. You could probably speed up opening the file by using the read option The relevant code in var df = new DicomFile();
try
{
df.File = Setup.ServiceProvider.GetService<IFileReferenceFactory>().Create(fileName);
using var source = new FileByteSource(df.File, readOption, largeObjectSize);
var reader = new DicomFileReader();
var result = reader.Read(
source,
new DicomDatasetReaderObserver(df.FileMetaInfo),
new DicomDatasetReaderObserver(df.Dataset, fallbackEncoding),
stop);
... With the respective values for This is just an (untested) idea - maybe somebody else knows a better way. |
Beta Was this translation helpful? Give feedback.
-
I have a simiar request. I need a quick check if two DICOM files do have identical content. Therefore I want to calcualte a hash of the file for a first check. But this hash should not include the group 2, which is changed always, because it contains the senders AETitle and so on. So the actual content relevant for the hash would be group 8 and higher. So I would need the offset within the dicom file , where the group 8 is starting. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I am interested in getting the byte offset to the beginning of the pixel data, in order to directly grab the frame data.
My application uses fo-dicom to pre-parse DICOM files for whole slide imaging application, and I maintain a separate index file that better suits my application needs for quick access to frame data. The indexed files will not be modified once brought into the system, so I do not need to maintain the index.
I am finding that for very large files, across network, there is a considerable cost for parsing on DicomFile.Open ( or OpenAsync ) for very large files ( although local access is pretty speedy ).
My plan is to record the byte offset to the beginning of the frame data, along with the offset from the Offset Table for the pixel data in my external index, and use that to directly grab the image data that I want ( sidestepping fo-dicom ), in order to avoid the parsing cost.
Is there a straightforward way to calculate the offset to the beginning of the pixel data? My current thought is to just brute force search for the Pixel Data tag and record the offset from that. I can imagine some risk here maybe. If fo-dicom can provide that info instead, it would be great. Any other ideas or approaches to this issue would be appreciated.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions