# Algorithms

**URL:** https://discourse.itk.org/c/algorithms/7.md?no_subcategories=false&page=9

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

**Page:** 10

---

## [Use Simpleitk to reading DICOM series In multiple folders](https://discourse.itk.org/t/use-simpleitk-to-reading-dicom-series-in-multiple-folders/4493)

<div class="topic-metadata">

**Author:** [@kelly90802](https://discourse.itk.org/u/kelly90802)\
**Replies:** 1\
**Last updated:** [October 13, 2021, 12:47pm UTC](https://discourse.itk.org/t/use-simpleitk-to-reading-dicom-series-in-multiple-folders/4493 "2021-10-13T12:47:12Z")

</div>

Hi all, Maybe someone here would know- I want to get the series IDs of each patient. the sitk.ImageSeriesReader.GetGDCMSeriesIDs need all dicom files are included in the file\_path. But, what if the folder structure is…

---

## [Image conversion from 3D volume to 2D slices](https://discourse.itk.org/t/image-conversion-from-3d-volume-to-2d-slices/1857)

<div class="topic-metadata">

**Author:** [@srbn.ghosh89](https://discourse.itk.org/u/srbn.ghosh89)\
**Replies:** 6\
**Last updated:** [October 2, 2021, 11:49am UTC](https://discourse.itk.org/t/image-conversion-from-3d-volume-to-2d-slices/1857 "2021-10-02T11:49:33Z")

</div>

I am finding difficulty to convert a 3D nifti image to slices. Here is a screenshot of input 3D image. And the slices should look like this. But using this code I am getting this type of output slice. The code …

---

## [Displacement field to (BSpline) Transform](https://discourse.itk.org/t/displacement-field-to-bspline-transform/4434)

<div class="topic-metadata">

**Author:** [@Mikhail](https://discourse.itk.org/u/Mikhail)\
**Replies:** 8\
**Last updated:** [September 23, 2021, 8:13pm UTC](https://discourse.itk.org/t/displacement-field-to-bspline-transform/4434 "2021-09-23T20:13:01Z")

</div>

Dear community, I am looking for a way to obtain a (bspline) transformation given a displacement field (x y z 3) defined on a regular grid. The reason I want to obtain this transformation is to reduce the memory consump…

---

## [Poor affine registration results using LandmarkBasedTransformInitializer](https://discourse.itk.org/t/poor-affine-registration-results-using-landmarkbasedtransforminitializer/4403)

<div class="topic-metadata">

**Author:** [@ctorti](https://discourse.itk.org/u/ctorti)\
**Replies:** 8\
**Last updated:** [September 22, 2021, 4:23pm UTC](https://discourse.itk.org/t/poor-affine-registration-results-using-landmarkbasedtransforminitializer/4403 "2021-09-22T16:23:16Z")

</div>

Hi all, I’m getting bad affine registration results for certain combinations of moving and fixed images. To rule out the possibility of poor initial alignment, I considered affine and bspline CT-to-MR registrations us…

---

## [Difference between numberofFixedImageSamples and numberofSpatialSamples](https://discourse.itk.org/t/difference-between-numberoffixedimagesamples-and-numberofspatialsamples/4431)

<div class="topic-metadata">

**Author:** [@c.spanakis83](https://discourse.itk.org/u/c.spanakis83)\
**Replies:** 1\
**Last updated:** [September 20, 2021, 1:26pm UTC](https://discourse.itk.org/t/difference-between-numberoffixedimagesamples-and-numberofspatialsamples/4431 "2021-09-20T13:26:58Z")

</div>

Hello I want to use Mutual Information (specifically Mattes’ Mutual Information) in order to align 2 medical images. However, I found that it has two methods: SetNumberofFixedImageSamples (unsigned int num) SetNumberof…

---

## [Convert CT mask to PET mask](https://discourse.itk.org/t/convert-ct-mask-to-pet-mask/3775)

<div class="topic-metadata">

**Author:** [@Jakob\_Riber\_Rasmusse](https://discourse.itk.org/u/Jakob_Riber_Rasmusse)\
**Replies:** 6\
**Last updated:** [September 8, 2021, 9:42am UTC](https://discourse.itk.org/t/convert-ct-mask-to-pet-mask/3775 "2021-09-08T09:42:25Z")

</div>

Hello Apoligies if my question is outside the scope of this forum, but here it goes: I am in a situation where I have to convert a mask created on a CT image in to a mask that applies to a PET image. E.g. from 480x480x…

---

## [Image Spacing and BSpline Registration Variability](https://discourse.itk.org/t/image-spacing-and-bspline-registration-variability/4346)

<div class="topic-metadata">

**Author:** [@cdcooke](https://discourse.itk.org/u/cdcooke)\
**Replies:** 9\
**Last updated:** [August 31, 2021, 7:26pm UTC](https://discourse.itk.org/t/image-spacing-and-bspline-registration-variability/4346 "2021-08-31T19:26:28Z")

</div>

Hello All - I have run across something that I don’t quite understand, but I’m hoping someone here can help. I am trying to register 2 medical images (PET, if that matters) using a BSpline registration. The images are…

---

## [interpolate 3d image where the xy planes have 70nm between each other](https://discourse.itk.org/t/interpolate-3d-image-where-the-xy-planes-have-70nm-between-each-other/4383)

<div class="topic-metadata">

**Author:** [@caniko](https://discourse.itk.org/u/caniko)\
**Replies:** 6\
**Last updated:** [August 31, 2021, 7:08am UTC](https://discourse.itk.org/t/interpolate-3d-image-where-the-xy-planes-have-70nm-between-each-other/4383 "2021-08-31T07:08:16Z")

</div>

I am working with electronmicroscopy where we have brain slices along the z-axis, 70nm. I would like to compute the image data that is missing between each image slice, and need help picking the right algorithm (if there…

---

## [How removes holes at the boundaries of the 3d image faster?](https://discourse.itk.org/t/how-removes-holes-at-the-boundaries-of-the-3d-image-faster/4349)

<div class="topic-metadata">

**Author:** [@ainor](https://discourse.itk.org/u/ainor)\
**Replies:** 16\
**Last updated:** [August 30, 2021, 5:14am UTC](https://discourse.itk.org/t/how-removes-holes-at-the-boundaries-of-the-3d-image-faster/4349 "2021-08-30T05:14:13Z")

</div>

I am segmenting an image, but when I apply a threshold filter there are some holes left in the surface that I need to fill. To fill in the holes I am using BinaryMorphologicalClosingImageFilter but it is very slow, even …

---

## [Interpolate ITK image data at missing / masked pixels (CUDA / C++)](https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363)

<div class="topic-metadata">

**Author:** [@Thibault\_Pelletier](https://discourse.itk.org/u/Thibault_Pelletier)\
**Replies:** 2\
**Last updated:** [August 26, 2021, 7:47am UTC](https://discourse.itk.org/t/interpolate-itk-image-data-at-missing-masked-pixels-cuda-c/4363 "2021-08-26T07:47:59Z")

</div>

Hi everyone, I would like to know if there are any algorithms in ITK which would allow me to interpolate linearily missing pixels of a 2D image data (preferably with a CUDA implementation)? To detail a little more my q…

---

## [Is it possible to use GPU for resample filter in simpleITK and Windows?](https://discourse.itk.org/t/is-it-possible-to-use-gpu-for-resample-filter-in-simpleitk-and-windows/4357)

<div class="topic-metadata">

**Author:** [@TY\_Park](https://discourse.itk.org/u/TY_Park)\
**Replies:** 3\
**Last updated:** [August 25, 2021, 6:26pm UTC](https://discourse.itk.org/t/is-it-possible-to-use-gpu-for-resample-filter-in-simpleitk-and-windows/4357 "2021-08-25T18:26:01Z")

</div>

Is it possible to use GPU for image resample in simpleITK or ITK? I checked the previous post, in that, one of the answers was to use the “itk-elastic-opencl” But it seems like work only on Linux Is there any other wa…

---

## [Extract an oblique 2D slice from a 3D volume](https://discourse.itk.org/t/extract-an-oblique-2d-slice-from-a-3d-volume/4137)

<div class="topic-metadata">

**Author:** [@ainor](https://discourse.itk.org/u/ainor)\
**Replies:** 3\
**Last updated:** [May 20, 2021, 1:00pm UTC](https://discourse.itk.org/t/extract-an-oblique-2d-slice-from-a-3d-volume/4137 "2021-05-20T13:00:02Z")

</div>

Hi, can someone give me an idea on how to extract an oblique 2D slice from a 3D volume with a given thickness?

---

## [How to store the segmented results in a container in itk?](https://discourse.itk.org/t/how-to-store-the-segmented-results-in-a-container-in-itk/4337)

<div class="topic-metadata">

**Author:** [@priyanka](https://discourse.itk.org/u/priyanka)\
**Replies:** 9\
**Last updated:** [August 20, 2021, 5:23pm UTC](https://discourse.itk.org/t/how-to-store-the-segmented-results-in-a-container-in-itk/4337 "2021-08-20T17:23:53Z")

</div>

I’m segmenting the dicom slices, I want to store the results in one container. So that I can use them for 3d reconstruction.

---

## [More support for reading DICOM series in parallel threads](https://discourse.itk.org/t/more-support-for-reading-dicom-series-in-parallel-threads/4321)

<div class="topic-metadata">

**Author:** [@Fijoy\_Vadakkumpadan](https://discourse.itk.org/u/Fijoy_Vadakkumpadan)\
**Replies:** 9\
**Last updated:** [August 11, 2021, 5:09pm UTC](https://discourse.itk.org/t/more-support-for-reading-dicom-series-in-parallel-threads/4321 "2021-08-11T17:09:18Z")

</div>

Parsing a DICOM directory recursively and reading all DICOM series from it is a time-consuming operation. I recently updated my application to parallelize this operation at the thread level as much as I can. But I found …

---

## [Extracting transformed patches from 3D image](https://discourse.itk.org/t/extracting-transformed-patches-from-3d-image/4317)

<div class="topic-metadata">

**Author:** [@Theoretialperson](https://discourse.itk.org/u/Theoretialperson)\
**Replies:** 4\
**Last updated:** [August 6, 2021, 5:22pm UTC](https://discourse.itk.org/t/extracting-transformed-patches-from-3d-image/4317 "2021-08-06T17:22:52Z")

</div>

In training AI algorithms for e.g. CT scan segmentation, patches are often extracted due to the GPU memory constraints. Additionally, patches are augmented with transforms such as rotation and scaling. Now I have implem…

---

## [Scaling (multiplying by a scalar value) an affine transformation](https://discourse.itk.org/t/scaling-multiplying-by-a-scalar-value-an-affine-transformation/4310)

<div class="topic-metadata">

**Author:** [@gdevenyi](https://discourse.itk.org/u/gdevenyi)\
**Replies:** 9\
**Last updated:** [August 1, 2021, 6:08pm UTC](https://discourse.itk.org/t/scaling-multiplying-by-a-scalar-value-an-affine-transformation/4310 "2021-08-01T18:08:12Z")

</div>

I’m interested in scaling (multiplying by a scalar) an affine transformation for reasons. My reading thus-far indicates that the mathematical constructions underlying the homogeneous matrix representation for an affine i…

---

## [Using LandmarkBasedTransformInitializer for BSpline registrations](https://discourse.itk.org/t/using-landmarkbasedtransforminitializer-for-bspline-registrations/4096)

<div class="topic-metadata">

**Author:** [@ctorti](https://discourse.itk.org/u/ctorti)\
**Replies:** 11\
**Last updated:** [July 19, 2021, 5:00pm UTC](https://discourse.itk.org/t/using-landmarkbasedtransforminitializer-for-bspline-registrations/4096 "2021-07-19T17:00:47Z")

</div>

Hi all, I originally posted this question on SimpleITK’s GitHub issues page, but became reminded about the Discourse forum while watching a SITK tutorial (somehow I completely forgot that the forum exists!). I’m re-pos…

---

## [Is it possible to measure memory transfer time and kernel execution time in ITK + GPU?](https://discourse.itk.org/t/is-it-possible-to-measure-memory-transfer-time-and-kernel-execution-time-in-itk-gpu/4261)

<div class="topic-metadata">

**Author:** [@Rafael\_Palomar](https://discourse.itk.org/u/Rafael_Palomar)\
**Replies:** 2\
**Last updated:** [July 14, 2021, 8:21am UTC](https://discourse.itk.org/t/is-it-possible-to-measure-memory-transfer-time-and-kernel-execution-time-in-itk-gpu/4261 "2021-07-14T08:21:36Z")

</div>

When benchmarking GPU algorithms it is important to measure kernel execution time separated from memory transfer times (CPU-\>GPU and GPU-\>CPU). Is it possible to measure these times separately for existing algorithms (e…

---

## [How to get a Bitmap object in VS from ImageFileReader object?](https://discourse.itk.org/t/how-to-get-a-bitmap-object-in-vs-from-imagefilereader-object/4232)

<div class="topic-metadata">

**Author:** [@Armando](https://discourse.itk.org/u/Armando)\
**Replies:** 4\
**Last updated:** [June 28, 2021, 12:48pm UTC](https://discourse.itk.org/t/how-to-get-a-bitmap-object-in-vs-from-imagefilereader-object/4232 "2021-06-28T12:48:11Z")

</div>

Hi. How to get a Bitmap object like CBitmap in VS from ImageFileReader object? I can write the image obtained from ImageFileReader into a BMP file and then load it using LoadBitmap(…) function of Visual Studio and then…

---

## [Adjusting demons algorism parameters](https://discourse.itk.org/t/adjusting-demons-algorism-parameters/4217)

<div class="topic-metadata">

**Author:** [@madwilliam](https://discourse.itk.org/u/madwilliam)\
**Replies:** 3\
**Last updated:** [June 27, 2021, 9:06pm UTC](https://discourse.itk.org/t/adjusting-demons-algorism-parameters/4217 "2021-06-27T21:06:51Z")

</div>

Hello guys, Our lab is using the Demons algorithm through SimpleITK to register some microscopy images to a template. Right now the alignment take up up to 130 gigs of ram for 2 gig images and is rather slow. Also ali…

---

## [Is there a minimum number of slices when running the N4 Filter](https://discourse.itk.org/t/is-there-a-minimum-number-of-slices-when-running-the-n4-filter/4223)

<div class="topic-metadata">

**Author:** [@Tamar](https://discourse.itk.org/u/Tamar)\
**Replies:** 4\
**Last updated:** [June 24, 2021, 8:07am UTC](https://discourse.itk.org/t/is-there-a-minimum-number-of-slices-when-running-the-n4-filter/4223 "2021-06-24T08:07:57Z")

</div>

When running the N4 filter as part of my (c#) code, I see that if the input image has only 1 slice I get an error, even if I set ShrinkFactor=1. The error message is: Exception thrown in SimpleITK N4BiasFieldCorrectionI…

---

## [Highly variable affine registration results for repeated runs](https://discourse.itk.org/t/highly-variable-affine-registration-results-for-repeated-runs/4212)

<div class="topic-metadata">

**Author:** [@ctorti](https://discourse.itk.org/u/ctorti)\
**Replies:** 13\
**Last updated:** [June 17, 2021, 3:21pm UTC](https://discourse.itk.org/t/highly-variable-affine-registration-results-for-repeated-runs/4212 "2021-06-17T15:21:13Z")

</div>

Hi all, I’m working on a workflow that includes image registration, with allowance for rigid, affine or bspline transforms, and initialization using either moments, geometry or landmarks. Some background: My workflow …

---

## [Interpolate Bspline Transformation](https://discourse.itk.org/t/interpolate-bspline-transformation/4214)

<div class="topic-metadata">

**Author:** [@Mikhail](https://discourse.itk.org/u/Mikhail)\
**Replies:** 2\
**Last updated:** [June 17, 2021, 8:43am UTC](https://discourse.itk.org/t/interpolate-bspline-transformation/4214 "2021-06-17T08:43:51Z")

</div>

I have images of same object at t0 and t1. I have a bspline transformation that can be used to obtain the image at t1 from the image at t0. I would like to obtain an image at t0 \< tx \< t1. Is there a way to modify the b…

---

## [ImageRegistrationMethodv4 questions](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117)

<div class="topic-metadata">

**Author:** [@gcsharp](https://discourse.itk.org/u/gcsharp)\
**Replies:** 27\
**Last updated:** [June 3, 2021, 6:19pm UTC](https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117 "2021-06-03T18:19:25Z")

</div>

Hi all. I have been investigating the ITK v4 registration framework, and have a few questions/comments for discussion. There seem to be some v3 functionality missing in v4. For example, no FRPROptimizer, no MutualInf…

---

## [Resample multimodality image mismatch](https://discourse.itk.org/t/resample-multimodality-image-mismatch/4151)

<div class="topic-metadata">

**Author:** [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Replies:** 1\
**Last updated:** [May 24, 2021, 1:22pm UTC](https://discourse.itk.org/t/resample-multimodality-image-mismatch/4151 "2021-05-24T13:22:58Z")

</div>

Hi! I’m trying to create a new 3D image from two medical images (stir=fixed image and axial 3d=moving image). This new image is wanted to be in the same space that the STIR image. I’ve tried with sitk.resampleimage. W…

---

## [BSplineTransform object has no attribute SetCoefficientImages](https://discourse.itk.org/t/bsplinetransform-object-has-no-attribute-setcoefficientimages/4136)

<div class="topic-metadata">

**Author:** [@ctorti](https://discourse.itk.org/u/ctorti)\
**Replies:** 4\
**Last updated:** [May 19, 2021, 7:13am UTC](https://discourse.itk.org/t/bsplinetransform-object-has-no-attribute-setcoefficientimages/4136 "2021-05-19T07:13:07Z")

</div>

I used SimpleITK v1.2 to perform a BSpline image registation. I used BSplineTransformInitializer to initialize the registration: MeshSize = \[NumControlPts\] \* MovIm.GetDimension() InitialTx = sitk.BSplineTransformIniti…

---

## [Create a mask filling holes of the image](https://discourse.itk.org/t/create-a-mask-filling-holes-of-the-image/4116)

<div class="topic-metadata">

**Author:** [@zandarina](https://discourse.itk.org/u/zandarina)\
**Replies:** 3\
**Last updated:** [May 11, 2021, 2:22pm UTC](https://discourse.itk.org/t/create-a-mask-filling-holes-of-the-image/4116 "2021-05-11T14:22:03Z")

</div>

Hello, I have a question, I want to remove the table of dicom files. For that, I do an “open” to remove the table and an “close” to fill the image as a mask. The problem comes with “close” to fill in the image with a bi…

---

## [bug or feature SLIC SuperPixel Segmentation?](https://discourse.itk.org/t/bug-or-feature-slic-superpixel-segmentation/4091)

<div class="topic-metadata">

**Author:** [@dyoll](https://discourse.itk.org/u/dyoll)\
**Replies:** 11\
**Last updated:** [May 11, 2021, 1:16pm UTC](https://discourse.itk.org/t/bug-or-feature-slic-superpixel-segmentation/4091 "2021-05-11T13:16:56Z")

</div>

I am trying to use the SLIC SuperPixel Segmentation algorithm in ITK. However, it seems to behave in a strange way, generating areas that contain pixel values with very high intensity variations (for instance the eye re…

---

## [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++.

---

## [Add a rigid transform and a deformable transform together](https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083)

<div class="topic-metadata">

**Author:** [@hfeng](https://discourse.itk.org/u/hfeng)\
**Replies:** 2\
**Last updated:** [May 4, 2021, 11:47pm UTC](https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083 "2021-05-04T23:47:31Z")

</div>

I am trying to do a image registration that consists of two stages. The first stage is selected to be Versor3DRigid and the second stage is selected to be Demons. The first stage can give a transform, the second stage …

[Previous page](https://discourse.itk.org/c/algorithms/7.md?no_subcategories=false&page=8)

[Next page](https://discourse.itk.org/c/algorithms/7.md?no_subcategories=false&page=10)
