# Algorithms

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

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

**Page:** 9

---

## [Segmentation fault in geodesic active contour](https://discourse.itk.org/t/segmentation-fault-in-geodesic-active-contour/4865)

<div class="topic-metadata">

**Author:** [@Oddone-Scatena](https://discourse.itk.org/u/Oddone-Scatena)\
**Replies:** 2\
**Last updated:** [March 18, 2022, 6:16pm UTC](https://discourse.itk.org/t/segmentation-fault-in-geodesic-active-contour/4865 "2022-03-18T18:16:02Z")

</div>

I am segmentation fault with geodesic active contour. my code: using SmoothingFilterType\_Heart\_Seg = itk::CurvatureAnisotropicDiffusionImageFilter\<InternalImageType, InternalImageType\>; auto Smoothi…

---

## [Get the same views of 3D dicom image](https://discourse.itk.org/t/get-the-same-views-of-3d-dicom-image/4846)

<div class="topic-metadata">

**Author:** [@tutti](https://discourse.itk.org/u/tutti)\
**Replies:** 2\
**Last updated:** [March 5, 2022, 6:48am UTC](https://discourse.itk.org/t/get-the-same-views-of-3d-dicom-image/4846 "2022-03-05T06:48:43Z")

</div>

Hello everyone, I have two 3D images (creat from 2 different registration methods, 2 images with same size (476,512,512) origin (0,0,0), direction(1,0,0,0,1,0,0,0,1)). I visualized 2 images with matplotlib (same slice)…

---

## [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…

---

## [How should I write a function that takes two images as inputs?](https://discourse.itk.org/t/how-should-i-write-a-function-that-takes-two-images-as-inputs/4812)

<div class="topic-metadata">

**Author:** [@Oddone-Scatena](https://discourse.itk.org/u/Oddone-Scatena)\
**Replies:** 1\
**Last updated:** [February 18, 2022, 2:34pm UTC](https://discourse.itk.org/t/how-should-i-write-a-function-that-takes-two-images-as-inputs/4812 "2022-02-18T14:34:39Z")

</div>

Can I write a function that takes two images as inputs and calculates the min pixel this way? I am following the deepcopy example. Thanks template \<typename TImage\> void Min\_of\_Image(typename TImage::Pointer input, type…

---

## [Bspline Free form deformable registration](https://discourse.itk.org/t/bspline-free-form-deformable-registration/4586)

<div class="topic-metadata">

**Author:** [@VeerBal](https://discourse.itk.org/u/VeerBal)\
**Replies:** 103\
**Last updated:** [February 7, 2022, 9:17pm UTC](https://discourse.itk.org/t/bspline-free-form-deformable-registration/4586 "2022-02-07T21:17:50Z")

</div>

Hello . I’m trying to register two lung CT images from the same patient (baseline and post ) using the Bspline transformation algorithm . I have the dicom images as well as the lung and the airway masks . I have alread…

---

## [Itk orientimagefilter](https://discourse.itk.org/t/itk-orientimagefilter/4780)

<div class="topic-metadata">

**Author:** [@shainy\_25s](https://discourse.itk.org/u/shainy_25s)\
**Replies:** 3\
**Last updated:** [February 7, 2022, 12:40pm UTC](https://discourse.itk.org/t/itk-orientimagefilter/4780 "2022-02-07T12:40:23Z")

</div>

I’m trying to set the coordinate orientation for around 350 images using orientor filter the updation of this filter is taking around 19s for execution Is there a way to reduce this time /any alternate filter. Piece of…

---

## [Differences between Hessian3DToVesselnessMeasureImageFilter and SatoVesselnessFeatureGenerator](https://discourse.itk.org/t/differences-between-hessian3dtovesselnessmeasureimagefilter-and-satovesselnessfeaturegenerator/4764)

<div class="topic-metadata">

**Author:** [@Jonas](https://discourse.itk.org/u/Jonas)\
**Replies:** 2\
**Last updated:** [February 1, 2022, 9:09am UTC](https://discourse.itk.org/t/differences-between-hessian3dtovesselnessmeasureimagefilter-and-satovesselnessfeaturegenerator/4764 "2022-02-01T09:09:24Z")

</div>

Hi, Can you tell me the differences between those two filters ? It seems to me that the same filter has been implemented under 2 different frameworks. https://itk.org/Doxygen/html/classitk\_1\_1Hessian3DToVesselnessMeasu…

---

## [How to get the inverse displacement field using demons registration](https://discourse.itk.org/t/how-to-get-the-inverse-displacement-field-using-demons-registration/4771)

<div class="topic-metadata">

**Author:** [@KrisHan999](https://discourse.itk.org/u/KrisHan999)\
**Replies:** 1\
**Last updated:** [January 31, 2022, 8:32pm UTC](https://discourse.itk.org/t/how-to-get-the-inverse-displacement-field-using-demons-registration/4771 "2022-01-31T20:32:30Z")

</div>

Hi, I have tried to use the demons method to do the image registration as shown in DemonsRegistration2 — SimpleITK 2.0rc2 documentation. But I can only get the forward transformation. Is there any way that I can get the…

---

## [Apply Region Growing Segmentation Filter Multiple Times](https://discourse.itk.org/t/apply-region-growing-segmentation-filter-multiple-times/4747)

<div class="topic-metadata">

**Author:** [@Oddone-Scatena](https://discourse.itk.org/u/Oddone-Scatena)\
**Replies:** 7\
**Last updated:** [January 31, 2022, 6:11pm UTC](https://discourse.itk.org/t/apply-region-growing-segmentation-filter-multiple-times/4747 "2022-01-31T18:11:36Z")

</div>

Hello, I am currently sementing the trachea with ConnectedThresholdImageFilter. Several authors segment the trachea using explosion controlled region growing (eg. “Automatic lung segmentation from thoracic computed tomo…

---

## [Register axial 3d to STIR sequence space](https://discourse.itk.org/t/register-axial-3d-to-stir-sequence-space/4758)

<div class="topic-metadata">

**Author:** [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Replies:** 1\
**Last updated:** [January 27, 2022, 2:50pm UTC](https://discourse.itk.org/t/register-axial-3d-to-stir-sequence-space/4758 "2022-01-27T14:50:27Z")

</div>

Hi! There’s go my doubt: I have a spinal cord mask in axial 3d sequence and I want to locate this mask in STIR sequence (same day/moment acquisition): I have done some tries (first I’ve tried with the axial image wher…

---

## [What bool value should \`imageRegion.IsInside(zeroSizedRegion)\` return?](https://discourse.itk.org/t/what-bool-value-should-imageregion-isinside-zerosizedregion-return/4734)

<div class="topic-metadata">

**Author:** [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Replies:** 9\
**Last updated:** [January 26, 2022, 8:52pm UTC](https://discourse.itk.org/t/what-bool-value-should-imageregion-isinside-zerosizedregion-return/4734 "2022-01-26T20:52:44Z")

</div>

There appears a disagreement between the documentation of ImageRegion::IsInside(const Self &) and the actual behavior when the region passed as argument has zero as size value. ITK: itk::ImageRegion\< VImageDimension \> C…

---

## [Intensity transformation with Sigmoid filter](https://discourse.itk.org/t/intensity-transformation-with-sigmoid-filter/4735)

<div class="topic-metadata">

**Author:** [@Alsurayhi](https://discourse.itk.org/u/Alsurayhi)\
**Replies:** 2\
**Last updated:** [January 17, 2022, 9:33pm UTC](https://discourse.itk.org/t/intensity-transformation-with-sigmoid-filter/4735 "2022-01-17T21:33:01Z")

</div>

I have lung CT data and I want all the scans to be in the range (-1024 to 3000). I’m using the Sigmoid filter, my first question is how to choose alpha and beta parameters? I’m using SimpleITK, I wrote this script to pe…

---

## [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 …

---

## [N4 Bias Field Correction](https://discourse.itk.org/t/n4-bias-field-correction/3972)

<div class="topic-metadata">

**Author:** [@banikr](https://discourse.itk.org/u/banikr)\
**Replies:** 3\
**Last updated:** [March 24, 2021, 7:17pm UTC](https://discourse.itk.org/t/n4-bias-field-correction/3972 "2021-03-24T19:17:09Z")

</div>

Hello All, I want to apply bias field correction in 3D T1w MR volumes(including non-brain sections too). Images are in NIfTI format. Though it is recommended to use masks, I don’t have masks or atlas for the data. I sa…

---

## [Image Registration Trapped in Local Minimum - Workarounds?](https://discourse.itk.org/t/image-registration-trapped-in-local-minimum-workarounds/4646)

<div class="topic-metadata">

**Author:** [@sr1](https://discourse.itk.org/u/sr1)\
**Replies:** 4\
**Last updated:** [December 9, 2021, 7:28am UTC](https://discourse.itk.org/t/image-registration-trapped-in-local-minimum-workarounds/4646 "2021-12-09T07:28:25Z")

</div>

Hi, I do image registration using GradientDescentLineSearch, MultiScale and MattesMutualInformation. The algorithm converges and gives “okayish” results. However, if I hand-tune the resulting transformation, I get even…

---

## [Images with bad starting conditions](https://discourse.itk.org/t/images-with-bad-starting-conditions/4642)

<div class="topic-metadata">

**Author:** [@avispi](https://discourse.itk.org/u/avispi)\
**Replies:** 6\
**Last updated:** [December 8, 2021, 4:35pm UTC](https://discourse.itk.org/t/images-with-bad-starting-conditions/4642 "2021-12-08T16:35:04Z")

</div>

Hi. I’m new to ITK. I have a set of template + image pairs. The pairs are of a thermal template and visual photo image. There is a significant translation between the images. I need to solve other transformation par…

---

## [Image Registration: Learning rate for optimizer has no influence](https://discourse.itk.org/t/image-registration-learning-rate-for-optimizer-has-no-influence/4631)

<div class="topic-metadata">

**Author:** [@sr1](https://discourse.itk.org/u/sr1)\
**Replies:** 6\
**Last updated:** [December 7, 2021, 3:41pm UTC](https://discourse.itk.org/t/image-registration-learning-rate-for-optimizer-has-no-influence/4631 "2021-12-07T15:41:01Z")

</div>

Hi, I just followed the tutorial on 61\_Registration\_Introduction\_Continued and noted, that the convergence-speed does not change when I modify the learningRate of the optimizer I changed the value to learningRate=0 a…

---

## [GetDRRSiddonJacobsRayTracing returns empty image for certain angles](https://discourse.itk.org/t/getdrrsiddonjacobsraytracing-returns-empty-image-for-certain-angles/4626)

<div class="topic-metadata">

**Author:** [@Steven](https://discourse.itk.org/u/Steven)\
**Replies:** 3\
**Last updated:** [December 1, 2021, 9:38am UTC](https://discourse.itk.org/t/getdrrsiddonjacobsraytracing-returns-empty-image-for-certain-angles/4626 "2021-12-01T09:38:24Z")

</div>

I created a so-called “virtual C-arm” using the function GetDRRSiddonJacobsRayTracing Algirhtm \[1\], but for certain angles the resulting image is black. The following commands were used to generate the DRR’s. The angle …

---

## [ITK implementation of geometric vector/tensor image transformations](https://discourse.itk.org/t/itk-implementation-of-geometric-vector-tensor-image-transformations/4596)

<div class="topic-metadata">

**Author:** [@josempozo](https://discourse.itk.org/u/josempozo)\
**Replies:** 4\
**Last updated:** [November 23, 2021, 8:15am UTC](https://discourse.itk.org/t/itk-implementation-of-geometric-vector-tensor-image-transformations/4596 "2021-11-23T08:15:34Z")

</div>

I am developing a new algorithm on itk and require the transformation of images which have different tensorial nature (vector, covector, symmetric rank-2 tensor). I was convinced that itk has this already implemented but…

---

## [How to create spherical mask for all voxels of an organ](https://discourse.itk.org/t/how-to-create-spherical-mask-for-all-voxels-of-an-organ/4584)

<div class="topic-metadata">

**Author:** [@Jithendra\_Kumar\_V](https://discourse.itk.org/u/Jithendra_Kumar_V)\
**Replies:** 1\
**Last updated:** [November 15, 2021, 10:37pm UTC](https://discourse.itk.org/t/how-to-create-spherical-mask-for-all-voxels-of-an-organ/4584 "2021-11-15T22:37:49Z")

</div>

Hi, I am trying to iterate all the voxels of an organ. For each voxel, need to create a 30 mm spherical mask and get the corresponding standard deviation. Finally pick the voxels with least standard deviation. Please gu…

---

## [How to dilate a 3D label image while keeping its' original label values?](https://discourse.itk.org/t/how-to-dilate-a-3d-label-image-while-keeping-its-original-label-values/4550)

<div class="topic-metadata">

**Author:** [@andieku](https://discourse.itk.org/u/andieku)\
**Replies:** 4\
**Last updated:** [November 5, 2021, 10:51pm UTC](https://discourse.itk.org/t/how-to-dilate-a-3d-label-image-while-keeping-its-original-label-values/4550 "2021-11-05T22:51:30Z")

</div>

Hi, I am trying to use SimpleITK in Python to dilate all non-zero regions in a 3D label image while keeping the image’s original label values. I tried following this Multi-label Morphology example but sitk.Morphological…

---

## [Applying a 4x4 affine transform to a 3D volume](https://discourse.itk.org/t/applying-a-4x4-affine-transform-to-a-3d-volume/4555)

<div class="topic-metadata">

**Author:** [@joeykleingers](https://discourse.itk.org/u/joeykleingers)\
**Replies:** 3\
**Last updated:** [November 5, 2021, 7:17pm UTC](https://discourse.itk.org/t/applying-a-4x4-affine-transform-to-a-3d-volume/4555 "2021-11-05T19:17:40Z")

</div>

I am trying to apply a 4x4 affine transform to a 3D volume to rotate the volume 1 degree along the Y-axis. This is a very simple example that I am trying to prove works so that I can use a more complicated 4x4 transform…

---

## [Image Registration of binary images](https://discourse.itk.org/t/image-registration-of-binary-images/2911)

<div class="topic-metadata">

**Author:** [@Felippe\_Trigueiro\_An](https://discourse.itk.org/u/Felippe_Trigueiro_An)\
**Replies:** 3\
**Last updated:** [November 3, 2021, 6:28am UTC](https://discourse.itk.org/t/image-registration-of-binary-images/2911 "2021-11-03T06:28:52Z")

</div>

HI guys, I’d like to register two binary brain images. I tried to use the MSE, correlation and MI in the SimpleITK but the result was not so good, so what metric do you suggest? I think that I need a metric which compare…

---

## [Particle swarm optimization in image](https://discourse.itk.org/t/particle-swarm-optimization-in-image/4464)

<div class="topic-metadata">

**Author:** [@Jonas](https://discourse.itk.org/u/Jonas)\
**Replies:** 1\
**Last updated:** [October 27, 2021, 1:16pm UTC](https://discourse.itk.org/t/particle-swarm-optimization-in-image/4464 "2021-10-27T13:16:22Z")

</div>

Hi, I would like to experiment with Particle swarm optimization to see if I can retrieve some vessels centerlines from the sum of the paths of PSO particles. The ITK implementation seems to work only to find minimums, …

---

## [Unexpected Behavior of LinearInterpolateImageFunction](https://discourse.itk.org/t/unexpected-behavior-of-linearinterpolateimagefunction/4450)

<div class="topic-metadata">

**Author:** [@krm15](https://discourse.itk.org/u/krm15)\
**Replies:** 4\
**Last updated:** [October 27, 2021, 12:53pm UTC](https://discourse.itk.org/t/unexpected-behavior-of-linearinterpolateimagefunction/4450 "2021-10-27T12:53:14Z")

</div>

Here is an example of using the LineageInterpolateImageFunction from the ITKSphinxExamples repository: https://itk.org/ITKExamples/src/Core/ImageFunction/LinearlyInterpolatePositionInImage/Documentation.html In this ex…

---

## [Is there a skull stripping module in SimpleITK that can work with MultiVolume?](https://discourse.itk.org/t/is-there-a-skull-stripping-module-in-simpleitk-that-can-work-with-multivolume/4519)

<div class="topic-metadata">

**Author:** [@kliron](https://discourse.itk.org/u/kliron)\
**Replies:** 2\
**Last updated:** [October 24, 2021, 6:14am UTC](https://discourse.itk.org/t/is-there-a-skull-stripping-module-in-simpleitk-that-can-work-with-multivolume/4519 "2021-10-24T06:14:47Z")

</div>

I need to do brain extraction from a number of MRI time series (DSC perfusion data). I found this itk module which, unless I am missing something doesn’t seem to support 4D sequences. I can load my DICOM files as a tim…

---

## [BinaryErodeImageFilter erodes the entire foreground](https://discourse.itk.org/t/binaryerodeimagefilter-erodes-the-entire-foreground/4518)

<div class="topic-metadata">

**Author:** [@kliron](https://discourse.itk.org/u/kliron)\
**Replies:** 4\
**Last updated:** [October 22, 2021, 4:15am UTC](https://discourse.itk.org/t/binaryerodeimagefilter-erodes-the-entire-foreground/4518 "2021-10-22T04:15:26Z")

</div>

I have a 3D labelmap image with the values 1 for foreground and 0 for background. I want to erode 1-2 voxels from the edge of the foreground. This is my code: f = sitk.BinaryErodeImageFilter() f.SetKernelType(sitk.sitk…

---

## [Edit a segmentation programatically in simpleitk](https://discourse.itk.org/t/edit-a-segmentation-programatically-in-simpleitk/4512)

<div class="topic-metadata">

**Author:** [@kliron](https://discourse.itk.org/u/kliron)\
**Replies:** 6\
**Last updated:** [October 20, 2021, 7:07pm UTC](https://discourse.itk.org/t/edit-a-segmentation-programatically-in-simpleitk/4512 "2021-10-20T19:07:57Z")

</div>

Hello, I’m very new to itk/simpleitk. What I need to do is: Segment a volume in an image A (I do this in 3D Slicer, manually). In simpleitk, apply the segmentation in another image, B (assume A and B are different…

---

## [Binary erode while preserving cell topology](https://discourse.itk.org/t/binary-erode-while-preserving-cell-topology/4499)

<div class="topic-metadata">

**Author:** [@joachim](https://discourse.itk.org/u/joachim)\
**Replies:** 4\
**Last updated:** [October 18, 2021, 1:43pm UTC](https://discourse.itk.org/t/binary-erode-while-preserving-cell-topology/4499 "2021-10-18T13:43:14Z")

</div>

In Slicer using the Simple Filters module, I’ve been doing binary thresholding of a CT volume: But I want thinner walls so I thought I could fix this with binary erosion: The problem is that the black cells start…

---

## [Resample produces blurry results when just cropping](https://discourse.itk.org/t/resample-produces-blurry-results-when-just-cropping/4473)

<div class="topic-metadata">

**Author:** [@Theoretialperson](https://discourse.itk.org/u/Theoretialperson)\
**Replies:** 8\
**Last updated:** [October 14, 2021, 5:35pm UTC](https://discourse.itk.org/t/resample-produces-blurry-results-when-just-cropping/4473 "2021-10-14T17:35:01Z")

</div>

I found out I was getting slightly blurry results when using Resample just with cropping: import SimpleITK as sitk import matplotlib.pyplot as plt import numpy as np def myshow(img, title=None, margin=0.05, dpi=80): …

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

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