Comments (11)
Also did some recherche. A lot of topics are discussed in forums like comp.protocols.dicom, but this never seemed o be a topic there.
And even if i understood the standard in a way that the 1 bits in overlay are counting and the rest may be assumed as zero, and even if dropping the overlay because of 4 missing bits would contradict the principle of "be as tollerant as possible when receiving data and as strict as possible when creating data", I would now agree to the PR if you all understand this file as invalid.
from fo-dicom.
Throwing an exception was never a topic here in this issue. dcm4che does it, but I would not support this in fo-dicom.
The question in this issue was if we should draw the overlay except the last 4 bits and therefore be tollerant, or if we skip the whole overlay and therefore be more strict. This is why I said, that this would contratict the mantra.
from fo-dicom.
In this image the Overlay rows are 567 and overlay columns are 652, and there are 1 bit per pixel. This means, that the data must be of length:
567 * 652 / 8 = 46210.5
As you can see from the screenshot, the length of the data is
46210
When fo-dicom wants to get the overlay-data from the last 4 pixels, it does all the bit-shift operations, and has to access the 46211th byte of the overlaydata, but this is not present.
i wonder if this is valid, that the overlaydata contains too less data. I did not find something in DICOM standard, that the data may be less and the renderer has to assume that the missing data shall be 0, or similar.
This file could be fixed easily. the overlay renderer has to check if the data length before accessing, instead of assuming that all data is present.
from fo-dicom.
While I agree with @gofal that it is an invalid DICOM file, I do feel that we should simply ignore this invalid overlay data while rendering. See my pull request for a fix.
from fo-dicom.
No, I did not say that this DICOM image was invalid! I was wondering (a.k.a. asking) if this would be valid. I did not find something explicit that allows the pixel data to be shorter, but I also did not find something that says that the pixel data is required to have some minimal length.
This was a call for reading the standard. I did not have the time and wanted to do it later then.
from fo-dicom.
So, as I mentioned, I also could not find any spot in the standard, that says that the data needs to have a certain length.
Instead there is something like: https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.9.2.html
The overlay bits corresponding to all the pixels included in the Graphics shall be set to 1. All other bits are set to 0.
This can also be be interpretatet, that the OverlayData has to contain a 1 in all pixels that belog to the overlay graphic, everything else should be considered as 0.
There is also in the dicom-standard, that the value has to be of even length in bytes. So if they would have added the 4 0-bits, then they would also have to add 12 more bits, so that the data has a even length in the end, 46212 bytes. So dropping the 4 last bits if they are 0 might be fine.
from fo-dicom.
Ah sorry for misinterpreting your words, carry on. So you would append zeros as needed?
Do we know how other DICOM libraries handle this?
from fo-dicom.
yes, that is what I can read from the standard, that the OverlayData has to contain the 1 values, that correspond to the graphic, and the rest can be assumed for 0.
And no, I do not know what other libraries are doing. This issue requires some research.
from fo-dicom.
I very much doubt that the 0 bits are optional. As far as I understand, OverlayRows
/OverlayColumns
are handled the same way as Rows
/Columns
. Also the definition of OverlayData
points in this direction, as far as I understand it:
Overlay pixel data.
The order of pixels encoded for each overlay is left to right, top to bottom, i.e., the upper left pixel is encoded first followed by the remainder of the first row, followed by the first pixel of the 2nd row, then the remainder of the 2nd row and so on.
Also, the wording:
The overlay bits ... shall be set to 1. All other bits are set to 0.
sounds to me like they shall indeed be set, not assumed to be set.
I have seen overlay data that starts or ends outside of the actual image (e.g. with a negative offset) and of all sizes, but I have never seen overlay data not "filled up". This is no evidence to the contrary, of course...
from fo-dicom.
I think I agree with @mrbean-bremen
Also, I think I found how dcm4che handles it:
Looks like they ignore it. :-)
Edit: it also looks like they do a sort of "best attempt" at drawing the overlay data and ignoring the IndexOutOfRangeException when it occurs: https://github.com/dcm4che/dcm4che/blob/b69cac25c1f613acc725a8c1cbb738db871d0fb6/dcm4che-image/src/main/java/org/dcm4che3/image/Overlays.java#L288
but maybe that relates more to what you said @mrbean-bremen, about overlay data indices being shifted somewhat.
from fo-dicom.
I think silently ignoring the invalid overlay data is a better experience than throwing an Exception while trying to render. We could perhaps have also chosen the path to throw a clearer exception ("You cannot render this image because the overlay data pixels does not have the correct number of bytes!" or something like that. It would be better than IndexOutOfRange), but in most cases we're just receiving DICOM files from the modalities and we don't really have a say about it.
I think the proposed changes align nicely with the mantra indeed: be tolerant to input and strict with output.
from fo-dicom.
Related Issues (20)
- Question - How to Load PixelData as Fragments HOT 1
- ImageSharp is not free software - Disclaimer? HOT 5
- DICOM files where numeric tags contain "NaN" (don't ask) cause exceptions
- Race condition in GenericGrayscalePipeline
- Corrupt Multi-frame File - Consistent for all image sizes. HOT 2
- How to monitor the time for a SCU client to transfer multiple files at a time on the SCP Server side HOT 3
- Code in fo-dicom to apply window width and center on an image HOT 1
- TCP listener stuck while processing TLS handshake HOT 4
- HTJ2K Throwing exception HOT 2
- The SCU client transmits images to the fo-dicom c-store-scp, and the speed decreases sequentially after each task is transmitted
- Korean Hangul characters incorrectly read from dicom file HOT 2
- fo-dicom v5 Dependency Injection Documentation HOT 3
- DicomServer performance regression HOT 6
- Microsoft Code Analysis HOT 2
- Creating a TCP connection using `DicomClient.SendAsync()` does not take `AssociationRequestTimeoutInMs` into account HOT 4
- DicomValidation for VR PN HOT 17
- dataset AddOrUpdate not find Encod args HOT 4
- Support proper encoding of strings with multi-valued encodings HOT 1
- DicomJsonConverter throws for non-DicomElements HOT 1
- Decimal String not adhering to standard? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fo-dicom.