# ITK error : GDCM could not read the DICOM image showing “DicomImageReadWrite.exe has triggered a breakpoint.” error while debugging.

**URL:** <https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155>\
**Category:** Uncategorized\
**Created:** [August 16, 2019, 8:52am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155 "2019-08-16T08:52:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)\
**Post date:** [August 16, 2019, 8:52am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/1 "2019-08-16T08:52:27Z")

</div>

Hello,

I am trying to run DicomImageReadWrite.cxxx example from ITK website in Visual Studio 2019.  
I have my input dicom image in working directory and gave correct command arguments in Properties.  
But still while running the example following box pops up and while debugging it is showing “DicomImageReadWrite.exe has triggered a breakpoint.” error.

 ![Screenshot%20(6)](https://discourse.itk.org/uploads/default/original/1X/e584877a86b07193ea2c5137afd798fbad09cb48.png)  
 ![Screenshot%20(7)](https://discourse.itk.org/uploads/default/original/1X/739c81f5518c2c55dcc6d231454aa26c9735f03e.png)

Do anyone know what is the problem? And How to solve it?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 16, 2019, 2:45pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/2 "2019-08-16T14:45:08Z")

</div>

@mathieu.malaterre might know more, but you will probably need to provide the image you are trying to read.

---

<div class="post-metadata">

**Author:** ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)\
**Post date:** [August 19, 2019, 8:22am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/3 "2019-08-19T08:22:08Z")

</div>

I am trying to red following DICOM image.

[IMG019](https://discourse.itk.org/uploads/short-url/o8SXFk4ptDJPiX37imMmwnUoIue) (515.3 KB)

I am also trying to run this example in my Linux ubuntu system but still it is not detecting my DICOM image. Even also trying with Reading dicom series and it shows “No dicoms in: SER01”

Please help me to solve this problem.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 19, 2019, 2:42pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/4 "2019-08-19T14:42:11Z")

</div>

I get `Assertion failed: 0, file C:\Libs\ITK-5.0.1\Modules\ThirdParty\GDCM\src\gdcm\Source\MediaStorageAndFileFormat\gdcmRescaler.cxx, line 336`. The assert gets triggered [here](https://github.com/InsightSoftwareConsortium/ITK/blob/0774730bc8b5ecc03fb361063cdd1ff9490d528a/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx#L336), during writing as `unsigned char`. That doesn’t seem to be supported any longer. If the line `writer3->Update();` is commented out or removed, the example works.

@mathieu.malaterre, did when did GDCM lose the ability to write UCHAR images?

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 19, 2019, 9:03pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/5 "2019-08-19T21:03:38Z")

</div>

Interesting… That example, i took it from actual master branch Examples folder and run with arguments _IMG019 out1.dcm out2.mha out3.dcm_, seems to work for me if i comment out line:  
`writer3->SetImageIO( gdcmImageIO );`

Could you reproduce? Thanks. ( **Edit** : i don’t have DCMTKIO compiled)  
With or without setting UseInputMetaDataDictionaryOff.  
So generally GDCMIO still can write UCHAR images.

 ![qq1](https://discourse.itk.org/uploads/default/original/1X/6bae1ec7b6f5ff13acf12f7a1ec1426aa3725715.jpeg)

The problem without editing the example seems to be  
Slope=1 **Intercept=-1024**  
Where it comes from is not clear just now ( **edit** : it is from setting old gdcmImageIO, s. next post), writer takes re-scaled data and slope/intercept have to be **1/0** and function _Rescaler::InverseRescale_ should exit [here](https://github.com/InsightSoftwareConsortium/ITK/blob/0774730bc8b5ecc03fb361063cdd1ff9490d528a/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx#L304) , before the switch with assert(0).

**Edit** : BTW, _IMG019_ has rather seldom transfer syntax _Explicit VR Big Endian_, but i don’t think it is related to problems, just FYI, if someone will investigate the issue.

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 19, 2019, 9:47pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/6 "2019-08-19T21:47:50Z")

</div>

OK, seems that it is wrong to use single instance of gdcmImageIO for reader and for _writer3_. For _writer1_ it seems to be the purpose to copy imageIO, but how it can work with another, very different data. If i print gdcmImageIO **before** setting it to _writer3_ it has already

…  
Internal Component Type: unsigned\_short  
RescaleSlope: 1  
RescaleIntercept: -1024  
…

That is reason for errors, highly likely, isn’t it?

**Edit** : regarding applying inverse re-scale to int8/uint8 images in general - FYI, it was once added inside ITK by this [commit 2014](https://github.com/InsightSoftwareConsortium/ITK/commit/847ec2b79ac2cedaab6714678c0677793aa23a1e#diff-f69d45271be3b8433efc9962b19421d1), actually it is gone again. Anyway i think that part of example with _writer3_ is questionable. The re-scaled data is so different compared with original, it is not clear what the should be achieved by re-using the imageIO from the reader (patient name and id may be), anyway original slope and intercept should not be passed to re-scaled uchar image, it is clear.

---

<div class="post-metadata">

**Author:** ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)\
**Post date:** [August 20, 2019, 11:19am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/7 "2019-08-20T11:19:41Z")

</div>

I removed try & catch block of writer3-\>Update(); as you said.  
But still the example is not working for me. It is showing the same error.  
I don’t understand the reason.

Even I tried by removing writer3-\>SetImageIO( gdcmImageIO ); line.  
That is also not working for me.

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 20, 2019, 11:43am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/8 "2019-08-20T11:43:54Z")

</div>

Do you have arguments _IMG019 out1.dcm out2.mha out3.dcm_?  
With commenting out writer3-\>update **or** writer3-\>SetImageIO( gdcmImageIO ) there should be no assert, have tried just now again.

---

<div class="post-metadata">

**Author:** ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)\
**Post date:** [August 20, 2019, 12:40pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/10 "2019-08-20T12:40:45Z")

</div>

Yes, I have same arguments.  
But still its the same error.

 ![Screenshot%20(8)](https://discourse.itk.org/uploads/default/original/1X/1749f4ff8624d3986a8f721fc2940ad1938b9377.png)

 ![Screenshot%20(9)](https://discourse.itk.org/uploads/default/original/1X/98aed1df5f6465ff64523a5d5cc76d1495ec0eb5.png)

But now in my working directory I can see outputs. So it means the program is working?

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 20, 2019, 12:56pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/11 "2019-08-20T12:56:54Z")

</div>

With one of both workarounds (disable writer3 update or don’t set imageIO) i have no assert, may be something trivial? I see two files DicomImageReadWrite.cxx at the screenshot. Sorry, just guessing. I am testing on Linux, but i don’t think there is difference with Windows.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 20, 2019, 1:48pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/12 "2019-08-20T13:48:13Z")

</div>

Just commenting dfg does not work for me. I still get:

```nohighlight
Warning: In C:\Libs\ITK-5.0.1\Modules\ThirdParty\GDCM\src\gdcm\Source\DataStructureAndEncodingDefinition\gdcmMediaStorage.cxx, line 526, function gdcm::MediaStorage::SetFromModality
Unknown/Unhandle MediaStorage, but Pixel Data element found

```

I don’t have DCMTK enabled in this build, maybe that’s the reason it works for you Mihail and not for me. I am testing on Windows.

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 20, 2019, 1:52pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/13 "2019-08-20T13:52:47Z")

</div>

This warning didn’t go away, it is harmless (i hope). But assert in InverseRescale? It went for me.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 20, 2019, 1:55pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/14 "2019-08-20T13:55:33Z")

</div>

You are right. The warning is there, but the image gets written and program’s exit code is zero (success).

---

<div class="post-metadata">

**Author:** ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)\
**Post date:** [August 21, 2019, 8:25am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/15 "2019-08-21T08:25:00Z")

</div>

I also tried the same example in Linux system. It is working when I remove writer3-\>Update; line.  
But I don’t understand what is the problem with Visual Studio in Windows.  
If I try other examples also, those are also not working.

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 21, 2019, 9:31am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/16 "2019-08-21T09:31:49Z")

</div>

May be the problem is complicated structure of VS project directories or non-ascii characters, something like this, i guess, not sure.

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 22, 2019, 7:32am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/17 "2019-08-22T07:32:53Z")

</div>

May be you could try to run from _cmd_ like at the screenshot in this [post](https://discourse.itk.org/t/run-examples-from-windows-command-line/2105/3)

---

<div class="post-metadata">

**Author:** ![mathieu.malaterre](https://discourse.itk.org/user_avatar/discourse.itk.org/mathieu.malaterre/32/205_2.png) [@mathieu.malaterre](https://discourse.itk.org/u/mathieu.malaterre)\
**Post date:** [August 27, 2019, 8:19am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/18 "2019-08-27T08:19:14Z")

</div>

> [@dzenanz](#):
>
> I get `Assertion failed: 0, file C:\Libs\ITK-5.0.1\Modules\ThirdParty\GDCM\src\gdcm\Source\MediaStorageAndFileFormat\gdcmRescaler.cxx, line 336`. The assert gets triggered [here](https://github.com/InsightSoftwareConsortium/ITK/blob/0774730bc8b5ecc03fb361063cdd1ff9490d528a/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx#L336), during writing as `unsigned char`. That doesn’t seem to be supported any longer. If the line `writer3->Update();` is commented out or removed, the example works.
> 
> @mathieu.malaterre, did when did GDCM lose the ability to write UCHAR images?

GDCM did not lose ability to write 8bits image. The assert() you triggered indicate that you somehow try to rescale y = ax + b) onto an 8bits image. While this could be acceptable for academic, this does not make sense in the real world.

Let me know if I should dig further.

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 27, 2019, 10:02am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/19 "2019-08-27T10:02:46Z")

</div>

> GDCM did not lose ability to write 8bits image.

Sure, thank you for response, that assert was already cleared [here](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/5) and [here](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/14) (edited: typo)

---

<div class="post-metadata">

**Author:** ![mihail.isakov](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mihail.isakov](https://discourse.itk.org/u/mihail.isakov)\
**Post date:** [August 27, 2019, 10:41am UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/20 "2019-08-27T10:41:24Z")

</div>

@mathieu.malaterre BTW, there was one change related to rescale/slope and char images done in this [commit](https://github.com/InsightSoftwareConsortium/ITK/commit/847ec2b79ac2cedaab6714678c0677793aa23a1e#diff-f69d45271be3b8433efc9962b19421d1) 5 years ago and disappered again later. Were interesting to know what do you think about. Thank you.

---

<div class="post-metadata">

**Author:** ![mathieu.malaterre](https://discourse.itk.org/user_avatar/discourse.itk.org/mathieu.malaterre/32/205_2.png) [@mathieu.malaterre](https://discourse.itk.org/u/mathieu.malaterre)\
**Post date:** [August 29, 2019, 2:55pm UTC](https://discourse.itk.org/t/itk-error-gdcm-could-not-read-the-dicom-image-showing-dicomimagereadwrite-exe-has-triggered-a-breakpoint-error-while-debugging/2155/21 "2019-08-29T14:55:17Z")

</div>

@mihail.isakov Thanks for the pointer ! I do not know how it got lost. Anyway this is fixed in release:

- [https://github.com/malaterre/GDCM/commit/abd382282efd00d591daed21cf2d35acd5c22699](https://github.com/malaterre/GDCM/commit/abd382282efd00d591daed21cf2d35acd5c22699)
