# \#cpp

**URL:** https://discourse.itk.org/tag/cpp/174.md

[Latest](https://discourse.itk.org/latest.md) · [Categories](https://discourse.itk.org/categories.md) · [Tags](https://discourse.itk.org/tags.md)

---

## [std::mdspan interface for images](https://discourse.itk.org/t/std-mdspan-interface-for-images/7742)

<div class="topic-metadata">

**Author:** [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Replies:** 0\
**Last updated:** [April 2, 2026, 7:51pm UTC](https://discourse.itk.org/t/std-mdspan-interface-for-images/7742 "2026-04-02T19:51:10Z")

</div>

I know we can’t require C++23 anytime soon, but std::mdspan is quite relevant feature for ITK. Are there any thoughts about how to best exploit it, once we are able to rely on it?

---

## [Intermittent SIGSEGV in SignedMaurerDistanceMap](https://discourse.itk.org/t/intermittent-sigsegv-in-signedmaurerdistancemap/7714)

<div class="topic-metadata">

**Author:** [@e\_s](https://discourse.itk.org/u/e_s)\
**Replies:** 8\
**Last updated:** [February 25, 2026, 5:54pm UTC](https://discourse.itk.org/t/intermittent-sigsegv-in-signedmaurerdistancemap/7714 "2026-02-25T17:54:01Z")

</div>

Hello Everyone. I am experiencing an intermittent Segmentation Fault while using the itk::simple::SignedMaurerDistanceMap() function. Environment SimpleITK 2.4 (ITK 5.4), Ubuntu 24 with intel oneAPI 2025.1 (icpx) comp…

---

## [ImageRegistrationMethodv4 crashes Unexpectedly](https://discourse.itk.org/t/imageregistrationmethodv4-crashes-unexpectedly/5268)

<div class="topic-metadata">

**Author:** [@autobuyer](https://discourse.itk.org/u/autobuyer)\
**Replies:** 1\
**Last updated:** [March 12, 2025, 4:12pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-crashes-unexpectedly/5268 "2025-03-12T16:12:01Z")

</div>

Hello, I am relatively new ITK user and I am trying to implement affine registration in C++. After going through examples, I was able to put together a reasonable solution. However, when I run it it crashes unexpectedly…

---

## [Is it possible to create a user-defined cost function for registration?](https://discourse.itk.org/t/is-it-possible-to-create-a-user-defined-cost-function-for-registration/6677)

<div class="topic-metadata">

**Author:** [@Vidya](https://discourse.itk.org/u/Vidya)\
**Replies:** 0\
**Last updated:** [June 6, 2024, 7:35am UTC](https://discourse.itk.org/t/is-it-possible-to-create-a-user-defined-cost-function-for-registration/6677 "2024-06-06T07:35:45Z")

</div>

Hi, I am trying register two images with Bspline. I tried with itk::MeanSquaresImageToImageMetricv4 and itk::MattesMutualInformationImageToImageMetricv4. Both doesn’t give the correct registration for all the images. I w…

---

## [Install package itk 5](https://discourse.itk.org/t/install-package-itk-5/6591)

<div class="topic-metadata">

**Author:** [@Michael\_M](https://discourse.itk.org/u/Michael_M)\
**Replies:** 1\
**Last updated:** [April 24, 2024, 8:06pm UTC](https://discourse.itk.org/t/install-package-itk-5/6591 "2024-04-24T20:06:05Z")

</div>

Hello, I can install itk 5 via the longer process of cloning the repository and building it from scratch using cmake. However, i wanted to shorten and simplify the process by just downloading the package as described h…

---

## [ITK Affine transform doesn't translate the image as expected](https://discourse.itk.org/t/itk-affine-transform-doesnt-translate-the-image-as-expected/6584)

<div class="topic-metadata">

**Author:** [@Erezke](https://discourse.itk.org/u/Erezke)\
**Replies:** 0\
**Last updated:** [April 18, 2024, 5:45am UTC](https://discourse.itk.org/t/itk-affine-transform-doesnt-translate-the-image-as-expected/6584 "2024-04-18T05:45:40Z")

</div>

Hi I am trying to translate a DICOM image using an affine transform to a new position, but when I compare the centers of both images (before/after) it seems like the image did not move. Following is the code I use: ...…

---

## [How to use ITK to segment bones in osteoporotic patients](https://discourse.itk.org/t/how-to-use-itk-to-segment-bones-in-osteoporotic-patients/6181)

<div class="topic-metadata">

**Author:** [@AeBoPi](https://discourse.itk.org/u/AeBoPi)\
**Replies:** 2\
**Last updated:** [September 6, 2023, 4:12pm UTC](https://discourse.itk.org/t/how-to-use-itk-to-segment-bones-in-osteoporotic-patients/6181 "2023-09-06T16:12:28Z")

</div>

Osteoporosis reduces bone density and thus the strength of bone in the CT data set (shown in the figure), making it impossible to use traditional thresholding techniques to handle segmentation. I noticed that the M…

---

## [NVCC compilation error for ITK 5.3](https://discourse.itk.org/t/nvcc-compilation-error-for-itk-5-3/5612)

<div class="topic-metadata">

**Author:** [@mzukovec](https://discourse.itk.org/u/mzukovec)\
**Replies:** 5\
**Last updated:** [May 27, 2023, 1:55am UTC](https://discourse.itk.org/t/nvcc-compilation-error-for-itk-5-3/5612 "2023-05-27T01:55:46Z")

</div>

Hello. When I try to use image reading functionality inside .cu file, I get compilation errors, whereas if I put the same code inside .cpp file, which is compiler using regular host compiler, the code normally compiles. …

---

## [FFT Correlation: Normalized Sum of Square Difference](https://discourse.itk.org/t/fft-correlation-normalized-sum-of-square-difference/5827)

<div class="topic-metadata">

**Author:** [@elapins](https://discourse.itk.org/u/elapins)\
**Replies:** 1\
**Last updated:** [March 24, 2023, 4:06pm UTC](https://discourse.itk.org/t/fft-correlation-normalized-sum-of-square-difference/5827 "2023-03-24T16:06:45Z")

</div>

Hello, I am wondering if it would be possible to extend the FFTNormalizedCrossCorrelation function to use Normalized Sum of Square Differences instead of Cross Correlation metric? Thank you!

---

## [How to use Cuberille module with vcpkg](https://discourse.itk.org/t/how-to-use-cuberille-module-with-vcpkg/5813)

<div class="topic-metadata">

**Author:** [@daniel\_123](https://discourse.itk.org/u/daniel_123)\
**Replies:** 1\
**Last updated:** [March 20, 2023, 2:10pm UTC](https://discourse.itk.org/t/how-to-use-cuberille-module-with-vcpkg/5813 "2023-03-20T14:10:45Z")

</div>

Hi I am using ITK in a C++ project. I manage my dependencies with vcpkg. However, I do not manage to get the itk Cuberille remote module through vcpgk. How can I download, build, and use the Cuberille module with vcpkg? …

---

## [Transformation translation error?](https://discourse.itk.org/t/transformation-translation-error/5673)

<div class="topic-metadata">

**Author:** [@Matthieu\_Brucher](https://discourse.itk.org/u/Matthieu_Brucher)\
**Replies:** 0\
**Last updated:** [February 4, 2023, 6:59pm UTC](https://discourse.itk.org/t/transformation-translation-error/5673 "2023-02-04T18:59:22Z")

</div>

I’m trying to use the example from Register Image to Another Using Landmarks — v5.3.0 to set up a registration based on matching set of points. The estimated transform seems to me OK: AffineTransform (0x157604c30) RTTI…

---

## [How to separate layers from a NRRD file?](https://discourse.itk.org/t/how-to-separate-layers-from-a-nrrd-file/5661)

<div class="topic-metadata">

**Author:** [@Sterben\_01](https://discourse.itk.org/u/Sterben_01)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 12:18am UTC](https://discourse.itk.org/t/how-to-separate-layers-from-a-nrrd-file/5661 "2023-02-01T00:18:21Z")

</div>

Hi! I am a beginner of ITK/VTK. Currently, I have an NRRD file, and it has three layers. If I want to separate it and write it to three files, which class should I use? I know how to read and write, but I don’t know how…

---

## [ThinPlateSplineWarp using landmarks](https://discourse.itk.org/t/thinplatesplinewarp-using-landmarks/5413)

<div class="topic-metadata">

**Author:** [@Nicolas\_Loiseau](https://discourse.itk.org/u/Nicolas_Loiseau)\
**Replies:** 0\
**Last updated:** [October 13, 2022, 3:42pm UTC](https://discourse.itk.org/t/thinplatesplinewarp-using-landmarks/5413 "2022-10-13T15:42:46Z")

</div>

Hello everything, I am new to this forum, so please forgive me if my post is not consistent. I’m using itk c++. My goal is to register two volumes with non rigid transformation (nifti volumes, from a medical dataset), …

---

## [The image is full of zero after using resample filter.](https://discourse.itk.org/t/the-image-is-full-of-zero-after-using-resample-filter/5232)

<div class="topic-metadata">

**Author:** [@Bugmaker](https://discourse.itk.org/u/Bugmaker)\
**Replies:** 10\
**Last updated:** [August 12, 2022, 12:55pm UTC](https://discourse.itk.org/t/the-image-is-full-of-zero-after-using-resample-filter/5232 "2022-08-12T12:55:00Z")

</div>

Hi, I am sorry for troubling you so many times. I am trying to resize my image from (530,530,604) -\>(512,512,604), then i use ResampleImageFilter, ScaleTransform and BSplineInterpolateImageFunction to do it. The conve…

---

## [Extract contours from 3D image](https://discourse.itk.org/t/extract-contours-from-3d-image/5209)

<div class="topic-metadata">

**Author:** [@Kap](https://discourse.itk.org/u/Kap)\
**Replies:** 2\
**Last updated:** [July 22, 2022, 6:39pm UTC](https://discourse.itk.org/t/extract-contours-from-3d-image/5209 "2022-07-22T18:39:10Z")

</div>

Dears, I am trying to extract the contour from an object after the procedure of the segmentation. The complie is error free but the output is an empty(black) image. Maybe the output image type is wrong ? Any ideas ? H…

---

## [Extract multiple 2D slices from a 3D volume.](https://discourse.itk.org/t/extract-multiple-2d-slices-from-a-3d-volume/5058)

<div class="topic-metadata">

**Author:** [@mzukovec](https://discourse.itk.org/u/mzukovec)\
**Replies:** 3\
**Last updated:** [June 13, 2022, 3:59pm UTC](https://discourse.itk.org/t/extract-multiple-2d-slices-from-a-3d-volume/5058 "2022-06-13T15:59:44Z")

</div>

Hi all. I can’t solve the image extraction error (invalidRequestedRegionError) if I try to extract 2 different slices using the same ExtractImageFilter from a given volume. In my program, I want to use a single Extract…

---

## [3D Pointset to Pointset registration issue](https://discourse.itk.org/t/3d-pointset-to-pointset-registration-issue/5043)

<div class="topic-metadata">

**Author:** [@rfenioux](https://discourse.itk.org/u/rfenioux)\
**Replies:** 5\
**Last updated:** [June 2, 2022, 3:23pm UTC](https://discourse.itk.org/t/3d-pointset-to-pointset-registration-issue/5043 "2022-06-02T15:23:29Z")

</div>

Hi everyone, I’m trying to make this example work with 3D pointsets. I’m using the same methods as the example (AffineTransform, JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4, RegistrationParameterScalesFromPhys…

---

## [How to get voxel coordinates(as in ITK snap ) from vtkimage viewer from mouse click](https://discourse.itk.org/t/how-to-get-voxel-coordinates-as-in-itk-snap-from-vtkimage-viewer-from-mouse-click/4719)

<div class="topic-metadata">

**Author:** [@SREERAG\_H](https://discourse.itk.org/u/SREERAG_H)\
**Replies:** 6\
**Last updated:** [March 3, 2022, 4:25pm UTC](https://discourse.itk.org/t/how-to-get-voxel-coordinates-as-in-itk-snap-from-vtkimage-viewer-from-mouse-click/4719 "2022-03-03T16:25:34Z")

</div>

Hello, I am trying to use ITK’s region growing algorithm for medical image segmentation. So to put the seedpoint i need exact voxel coordinates of the mouse click position in my vtkimageviewer. So how can I get those vo…

---

## [nifti to dicom conversion introduces negative intensities](https://discourse.itk.org/t/nifti-to-dicom-conversion-introduces-negative-intensities/4798)

<div class="topic-metadata">

**Author:** [@Keyn34](https://discourse.itk.org/u/Keyn34)\
**Replies:** 23\
**Last updated:** [February 20, 2022, 5:06pm UTC](https://discourse.itk.org/t/nifti-to-dicom-conversion-introduces-negative-intensities/4798 "2022-02-20T17:06:56Z")

</div>

Hello everyone! When I try to convert a nifti file to a dicom series with ImageSeriesWriter, I encounter weird behavior when inspecting the results with ITK-SNAP. For a few cases the intensity range shifts from only pos…

---

## [Difference between imposed motion (SimpleITK) and registration output (ITK, ITK-Snap)](https://discourse.itk.org/t/difference-between-imposed-motion-simpleitk-and-registration-output-itk-itk-snap/4714)

<div class="topic-metadata">

**Author:** [@Keyn34](https://discourse.itk.org/u/Keyn34)\
**Replies:** 10\
**Last updated:** [January 12, 2022, 9:57am UTC](https://discourse.itk.org/t/difference-between-imposed-motion-simpleitk-and-registration-output-itk-itk-snap/4714 "2022-01-12T09:57:46Z")

</div>

Hello once again everyone, A quick question concerning applying translation and rotation to volumes and then registering them to compare the results to the imposed motion: I have a python script that uses SimpleITK to …

---

## [building as dll and include for c++](https://discourse.itk.org/t/building-as-dll-and-include-for-c/4608)

<div class="topic-metadata">

**Author:** [@avispi](https://discourse.itk.org/u/avispi)\
**Replies:** 2\
**Last updated:** [December 5, 2021, 1:52pm UTC](https://discourse.itk.org/t/building-as-dll-and-include-for-c/4608 "2021-12-05T13:52:42Z")

</div>

Hi. I want to try using ITK for some c++ development. I want to use it as any other external library I use (such as opencv i.e.) Preferably- dll + lib + include but also static libs + include is fine I’m compiling i…

---

## [Encountering undefined Behavior when writing DICOM images](https://discourse.itk.org/t/encountering-undefined-behavior-when-writing-dicom-images/4587)

<div class="topic-metadata">

**Author:** [@Keyn34](https://discourse.itk.org/u/Keyn34)\
**Replies:** 4\
**Last updated:** [November 17, 2021, 3:26pm UTC](https://discourse.itk.org/t/encountering-undefined-behavior-when-writing-dicom-images/4587 "2021-11-17T15:26:05Z")

</div>

Hello everyone, I am currently encountering undefined behavior when trying to write a DICOM series with headers taken from another series. I use only the gdcmIO and loop through all files to read the header with ReadIma…

---

## [Unexpected Results for "MultiResImageRegistration1.cxx."](https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411)

<div class="topic-metadata">

**Author:** [@Keyn34](https://discourse.itk.org/u/Keyn34)\
**Replies:** 2\
**Last updated:** [September 13, 2021, 7:49am UTC](https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411 "2021-09-13T07:49:03Z")

</div>

Hello everyone! I just started out with ITK, with base knowledge from VTK. I wanted to work through some Registration examples towards Multi-Resolution Registration. The Hello World Registration example worked for me, …

---

## [Segmentation of aorta using itk](https://discourse.itk.org/t/segmentation-of-aorta-using-itk/4101)

<div class="topic-metadata">

**Author:** [@priyanka](https://discourse.itk.org/u/priyanka)\
**Replies:** 3\
**Last updated:** [May 7, 2021, 6:26am UTC](https://discourse.itk.org/t/segmentation-of-aorta-using-itk/4101 "2021-05-07T06:26:18Z")

</div>

I’m new to this topic. Suggest me best method for segmenting aorta from the series of dicoms using itk C++.

---

## [Crash on calling ImageFileReader::New() MSVS 2019](https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984)

<div class="topic-metadata">

**Author:** [@ljubak](https://discourse.itk.org/u/ljubak)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 3:32pm UTC](https://discourse.itk.org/t/crash-on-calling-imagefilereader-new-msvs-2019/3984 "2021-03-25T15:32:13Z")

</div>

Hello everyone! I have recently compiled ITK on Windows 7 using Community MSVS 2019. Now I am trying to get myself acquainted with ITK and I am trying out to compile the first examples. And immediately I run into a prob…
