# Algorithms

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

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

**Page:** 15

---

## [Histogram Python](https://discourse.itk.org/t/histogram-python/2480)

<div class="topic-metadata">

**Author:** [@fraca](https://discourse.itk.org/u/fraca)\
**Replies:** 1\
**Last updated:** [December 6, 2019, 2:59pm UTC](https://discourse.itk.org/t/histogram-python/2480 "2019-12-06T14:59:48Z")

</div>

Hi, i’m trying to write these lines in Python but i dont’t know how to declare the variables (size,upperbound,lowerbound,measurement). Can you help me? typedef itk::Statistics::Histogram\<PixelType, 1\> HistogramType; P…

---

## [How to pick filters available in ITK for 3D medical image segmentation](https://discourse.itk.org/t/how-to-pick-filters-available-in-itk-for-3d-medical-image-segmentation/2206)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 2\
**Last updated:** [December 2, 2019, 4:17am UTC](https://discourse.itk.org/t/how-to-pick-filters-available-in-itk-for-3d-medical-image-segmentation/2206 "2019-12-02T04:17:01Z")

</div>

Hi All, I was going over filters available in itk to develop and implement segmentation algorithm for a 3D CT scan image. There are so many filters to pick and choose for each stages of segmentation. Is there guidance o…

---

## [CurvatureAnisotropicDiff creates different result relative to volume size](https://discourse.itk.org/t/curvatureanisotropicdiff-creates-different-result-relative-to-volume-size/2437)

<div class="topic-metadata">

**Author:** [@Amine](https://discourse.itk.org/u/Amine)\
**Replies:** 11\
**Last updated:** [December 1, 2019, 3:20pm UTC](https://discourse.itk.org/t/curvatureanisotropicdiff-creates-different-result-relative-to-volume-size/2437 "2019-12-01T15:20:22Z")

</div>

Hi, in an attempt to get a preview of what CurvatureAnisotropicDiffusion will produce with less processing time i tried to run it in on a cropped volume to serve as a sample, however the final result on the complete volu…

---

## [KdTree Python](https://discourse.itk.org/t/kdtree-python/2427)

<div class="topic-metadata">

**Author:** [@fraca](https://discourse.itk.org/u/fraca)\
**Replies:** 3\
**Last updated:** [December 1, 2019, 3:17pm UTC](https://discourse.itk.org/t/kdtree-python/2427 "2019-12-01T15:17:47Z")

</div>

There’s a way to implement itk::Statistics::WeightedCentroidKdTreeGenerator and itk::Statistics::KdTreeBasedKmeansEstimator in python? EDIT: i’m trying also to use itk::SmoothingRecursiveGaussianImageFilter but it seems…

---

## [How to flip an image about a line defined by me](https://discourse.itk.org/t/how-to-flip-an-image-about-a-line-defined-by-me/2403)

<div class="topic-metadata">

**Author:** [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)\
**Replies:** 3\
**Last updated:** [November 30, 2019, 4:57pm UTC](https://discourse.itk.org/t/how-to-flip-an-image-about-a-line-defined-by-me/2403 "2019-11-30T16:57:46Z")

</div>

I have a 3D volume data and I want to flip the image (not with the central vertical line) with a plane that is predefined. Is there any work done in this direction in itk or sitk?

---

## [Linear interpolation and image direction](https://discourse.itk.org/t/linear-interpolation-and-image-direction/2458)

<div class="topic-metadata">

**Author:** [@Elli](https://discourse.itk.org/u/Elli)\
**Replies:** 1\
**Last updated:** [November 28, 2019, 3:13pm UTC](https://discourse.itk.org/t/linear-interpolation-and-image-direction/2458 "2019-11-28T15:13:26Z")

</div>

Dear all, I am trying to figure out one discrepancy I cannot explain. If I read in a mask with say direction identity and I linearly interpolate it I get slightly different results than when I interpolate this mask wit…

---

## [Changes In ITK Mattes Mutual Information Metric](https://discourse.itk.org/t/changes-in-itk-mattes-mutual-information-metric/2353)

<div class="topic-metadata">

**Author:** [@machadoL](https://discourse.itk.org/u/machadoL)\
**Replies:** 40\
**Last updated:** [November 28, 2019, 1:22pm UTC](https://discourse.itk.org/t/changes-in-itk-mattes-mutual-information-metric/2353 "2019-11-28T13:22:57Z")

</div>

Hi, Everyone! I have little experience on ITK, and little knowledge on C++, although, I am doing some studies on Mutual Information Metric in Registration Pipelines. :smile: I’ve been reading a lot about registration, …

---

## [CannyFilter Python ITK](https://discourse.itk.org/t/cannyfilter-python-itk/2435)

<div class="topic-metadata">

**Author:** [@fraca](https://discourse.itk.org/u/fraca)\
**Replies:** 2\
**Last updated:** [November 27, 2019, 1:59pm UTC](https://discourse.itk.org/t/cannyfilter-python-itk/2435 "2019-11-27T13:59:01Z")

</div>

I’m trying to reproduce this example in python https://itk.org/ITKExamples/src/Filtering/ImageFeature/DetectEdgesWithCannyFilter/Documentation.html but i have an error: TypeError: \<module 'ITKSmoothing'\> is a built-in mo…

---

## [Get 2D Bounding box from a 3D bounding box of a labelled image](https://discourse.itk.org/t/get-2d-bounding-box-from-a-3d-bounding-box-of-a-labelled-image/2433)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 2\
**Last updated:** [November 25, 2019, 1:38am UTC](https://discourse.itk.org/t/get-2d-bounding-box-from-a-3d-bounding-box-of-a-labelled-image/2433 "2019-11-25T01:38:56Z")

</div>

Hi I have a use case where I have got 3D segmented image. I extract 3D bounding box info from shape stats. For example VOI Shape Stats: 45 Physical Size 2019.880133789592 Bounding Box: (239, 215, 0, 93, 85, 20) Now For l…

---

## [MHA Numpy](https://discourse.itk.org/t/mha-numpy/2400)

<div class="topic-metadata">

**Author:** [@fraca](https://discourse.itk.org/u/fraca)\
**Replies:** 14\
**Last updated:** [November 15, 2019, 10:26pm UTC](https://discourse.itk.org/t/mha-numpy/2400 "2019-11-15T22:26:16Z")

</div>

I’m trying to write this code in Python, but i don’t know what i have to do when i have to create an iterator to build the mask, because i don’t know what are the values of the array created from mha file. typedef itk:…

---

## [SetSize, SetIndex Python](https://discourse.itk.org/t/setsize-setindex-python/2413)

<div class="topic-metadata">

**Author:** [@fraca](https://discourse.itk.org/u/fraca)\
**Replies:** 1\
**Last updated:** [November 15, 2019, 3:42pm UTC](https://discourse.itk.org/t/setsize-setindex-python/2413 "2019-11-15T15:42:54Z")

</div>

There’s a way to set the size and the index of an image in python? Because commands processedVolumeRegion.SetSize(processedVolumeSize) processedVolumeRegion.SetIndex(processedVolumeStart) report this error: Attribut…

---

## [How to register two images that do not have the same information?](https://discourse.itk.org/t/how-to-register-two-images-that-do-not-have-the-same-information/2404)

<div class="topic-metadata">

**Author:** [@Felippe\_Trigueiro\_An](https://discourse.itk.org/u/Felippe_Trigueiro_An)\
**Replies:** 2\
**Last updated:** [November 14, 2019, 3:22pm UTC](https://discourse.itk.org/t/how-to-register-two-images-that-do-not-have-the-same-information/2404 "2019-11-14T15:22:04Z")

</div>

I have two MRI images, but one image has the complete head and the other has some parts of the head cut, including some parts of the brain. So how can I register these images? PS: My initial investigation was firstly do…

---

## [ImageMomentsCalculator how to in python](https://discourse.itk.org/t/imagemomentscalculator-how-to-in-python/2402)

<div class="topic-metadata">

**Author:** [@kayarre](https://discourse.itk.org/u/kayarre)\
**Replies:** 1\
**Last updated:** [November 14, 2019, 4:16am UTC](https://discourse.itk.org/t/imagemomentscalculator-how-to-in-python/2402 "2019-11-14T04:16:56Z")

</div>

I want to use the imageMomentsCalculator to get the “center of mass” of an image how could one do this with the python interface? it appears its only indirectly available as part registration intialization?

---

## [Wrap ITK Python](https://discourse.itk.org/t/wrap-itk-python/2391)

<div class="topic-metadata">

**Author:** [@fraca](https://discourse.itk.org/u/fraca)\
**Replies:** 7\
**Last updated:** [November 8, 2019, 4:11pm UTC](https://discourse.itk.org/t/wrap-itk-python/2391 "2019-11-08T16:11:23Z")

</div>

I’m trying to convert a C++ ITK code in python, but i find some issues with this input: TemplateTypeError: itk.ImageFileReader is not wrapped for input type itk.Image\[itk.UL,3\]. But i don’t know hot to solve the problem …

---

## [itk.ImageToVTKImageFilter crashing Python](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018)

<div class="topic-metadata">

**Author:** [@Michael\_Hogg](https://discourse.itk.org/u/Michael_Hogg)\
**Replies:** 8\
**Last updated:** [November 7, 2019, 9:07am UTC](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018 "2019-11-07T09:07:12Z")

</div>

Hi, I am using itk and vtk in Python. Specifically I am trying to convert an ITK image to a VTK image using the function itk.ImageToVTKImageFilter. I am currently trying to replicate the code here. If I even try to acce…

---

## [How to resize a 3D image](https://discourse.itk.org/t/how-to-resize-a-3d-image/2379)

<div class="topic-metadata">

**Author:** [@Felippe\_Trigueiro\_An](https://discourse.itk.org/u/Felippe_Trigueiro_An)\
**Replies:** 1\
**Last updated:** [November 5, 2019, 9:35pm UTC](https://discourse.itk.org/t/how-to-resize-a-3d-image/2379 "2019-11-05T21:35:59Z")

</div>

Hi, I’m trying to resize a 3D image to an specific size, but I’m getting as a result a white image with some black slices. Here is the code: sitk::Image imResize3(sitk::Image input, sitk::Image output\_size\_image) { …

---

## [Incorrect Result in Registration](https://discourse.itk.org/t/incorrect-result-in-registration/2373)

<div class="topic-metadata">

**Author:** [@Felippe\_Trigueiro\_An](https://discourse.itk.org/u/Felippe_Trigueiro_An)\
**Replies:** 1\
**Last updated:** [November 4, 2019, 2:44am UTC](https://discourse.itk.org/t/incorrect-result-in-registration/2373 "2019-11-04T02:44:49Z")

</div>

I am doing an affine registration using mutual information and I am getting incorrect results when trying to register the MNI atlas 1mm with the vanderbuild database. The images of the vanderbuilt data base differ from …

---

## [Combine shape stats from multiple labelled 2D slices](https://discourse.itk.org/t/combine-shape-stats-from-multiple-labelled-2d-slices/2366)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 2\
**Last updated:** [November 2, 2019, 3:01am UTC](https://discourse.itk.org/t/combine-shape-stats-from-multiple-labelled-2d-slices/2366 "2019-11-02T03:01:23Z")

</div>

Hi, Post applying segmentation filters on a 3D image, I gather shape stats for each 2D slice. How do I combine shape stats for each of 2D slices into one data structure. Is there simple ITK filter for such operation or I…

---

## [Understanding Seed based Confidence Connected SimpleITK Filter](https://discourse.itk.org/t/understanding-seed-based-confidence-connected-simpleitk-filter/2349)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 6\
**Last updated:** [November 2, 2019, 2:53am UTC](https://discourse.itk.org/t/understanding-seed-based-confidence-connected-simpleitk-filter/2349 "2019-11-02T02:53:23Z")

</div>

Hi, I am using seed based ConfidenceConnected Filter to find the target of my interest in 3D image. The shape of target is different in each slice in the 3D image. I get much better results than Thresholding methods I tr…

---

## [Buffer overflow in getting properties](https://discourse.itk.org/t/buffer-overflow-in-getting-properties/2363)

<div class="topic-metadata">

**Author:** [@msh\_smlv](https://discourse.itk.org/u/msh_smlv)\
**Replies:** 2\
**Last updated:** [October 30, 2019, 11:32am UTC](https://discourse.itk.org/t/buffer-overflow-in-getting-properties/2363 "2019-10-30T11:32:52Z")

</div>

Hello! During an internal security assessment of the medical ML pipeline based on Simple-itk we found buffer-overflow in DicomReader. I guess that it happens because you use the buffer which is located on the stack for…

---

## [To perform histogram equilization in ITK](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358)

<div class="topic-metadata">

**Author:** [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)\
**Replies:** 3\
**Last updated:** [October 28, 2019, 2:00pm UTC](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358 "2019-10-28T14:00:06Z")

</div>

Is there any code or example to perform histogram equilization in itk or simple itk?

---

## [Create mask for 3D image based on plane](https://discourse.itk.org/t/create-mask-for-3d-image-based-on-plane/2347)

<div class="topic-metadata">

**Author:** [@jbi35](https://discourse.itk.org/u/jbi35)\
**Replies:** 3\
**Last updated:** [October 28, 2019, 1:11pm UTC](https://discourse.itk.org/t/create-mask-for-3d-image-based-on-plane/2347 "2019-10-28T13:11:33Z")

</div>

Hi there, I am trying to solve the following problem. I have created a 3D segmentation with SimpleITK which I would like to split into two parts using a plane defined by the normal vector and point. My goal is to set th…

---

## [Organ Identification from Head-To-Toe CT scan](https://discourse.itk.org/t/organ-identification-from-head-to-toe-ct-scan/2296)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 9\
**Last updated:** [October 22, 2019, 1:49am UTC](https://discourse.itk.org/t/organ-identification-from-head-to-toe-ct-scan/2296 "2019-10-22T01:49:44Z")

</div>

Hi , Here is the problem and solution proposal I am planning to develop. Problem: I wish to segment HEAD-TO-TOE CT scan and identify organs from it. For example which slices has Heart or which has Bladder or which …

---

## [Compose image from different modality with different number of slices](https://discourse.itk.org/t/compose-image-from-different-modality-with-different-number-of-slices/2286)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 14\
**Last updated:** [October 19, 2019, 11:56pm UTC](https://discourse.itk.org/t/compose-image-from-different-modality-with-different-number-of-slices/2286 "2019-10-19T23:56:34Z")

</div>

Hi, I want to combine images from different modality into one composed image and then perform segmentation on it. My q is does itk have provision to compose two n dimensional images where number of slices in both differ…

---

## [grayscale segmentation from binary mask](https://discourse.itk.org/t/grayscale-segmentation-from-binary-mask/1756)

<div class="topic-metadata">

**Author:** [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)\
**Replies:** 13\
**Last updated:** [October 14, 2019, 4:40am UTC](https://discourse.itk.org/t/grayscale-segmentation-from-binary-mask/1756 "2019-10-14T04:40:35Z")

</div>

Hi guys, I’ve roughly segmented the liver using confidence connected. I have obtained a binary mask but what I need is to create an image containing ONLY the segmented liver using that mask. What I have to do is like ‘mu…

---

## [Does ITK already multiplies Rescale slope for each PET scan slice?](https://discourse.itk.org/t/does-itk-already-multiplies-rescale-slope-for-each-pet-scan-slice/2317)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 2\
**Last updated:** [October 12, 2019, 10:36pm UTC](https://discourse.itk.org/t/does-itk-already-multiplies-rescale-slope-for-each-pet-scan-slice/2317 "2019-10-12T22:36:59Z")

</div>

Hi, Does ITK reader already considers multiplying rescale slope to the stored value of pixel intensity? I want to confirm before I do this conversion of each pixel value in each slice of a 3D PET scan Thanks, Jiten

---

## [Problem calculating volume ITK mesh](https://discourse.itk.org/t/problem-calculating-volume-itk-mesh/2297)

<div class="topic-metadata">

**Author:** [@Elli](https://discourse.itk.org/u/Elli)\
**Replies:** 3\
**Last updated:** [October 7, 2019, 5:56pm UTC](https://discourse.itk.org/t/problem-calculating-volume-itk-mesh/2297 "2019-10-07T17:56:27Z")

</div>

Dear all, I am facing a problem calculating the volume of an ITK mesh. Originally I have an image mask and converted this mask to a triangle mesh. In order to calculate the surface, I wanted to convert this mesh to a s…

---

## [Alpha-Mutual Information for multimodal images with different number of feature channels](https://discourse.itk.org/t/alpha-mutual-information-for-multimodal-images-with-different-number-of-feature-channels/2272)

<div class="topic-metadata">

**Author:** [@take5v](https://discourse.itk.org/u/take5v)\
**Replies:** 3\
**Last updated:** [October 1, 2019, 3:34pm UTC](https://discourse.itk.org/t/alpha-mutual-information-for-multimodal-images-with-different-number-of-feature-channels/2272 "2019-10-01T15:34:40Z")

</div>

Hi, There have been some studies done on high dimensional image registration using \\alpha-MI (Staring et al, 2009). The implementation of alpha-Mutual Information is available in elastix: http://elastix.isi.uu.nl/doxyge…

---

## [How to iterate over each Superpixel?](https://discourse.itk.org/t/how-to-iterate-over-each-superpixel/2279)

<div class="topic-metadata">

**Author:** [@Jigabytes](https://discourse.itk.org/u/Jigabytes)\
**Replies:** 0\
**Last updated:** [September 29, 2019, 9:24pm UTC](https://discourse.itk.org/t/how-to-iterate-over-each-superpixel/2279 "2019-09-29T21:24:36Z")

</div>

Hi, I used ITK’s SLIC algo on 3D image and now for each slice I want to iterate over each segment(super pixels) in each 2D slice and extract intensity values for them. Does anyone guide what would be best possible way …

---

## [image registration using mutual information](https://discourse.itk.org/t/image-registration-using-mutual-information/1746)

<div class="topic-metadata">

**Author:** [@lorystays](https://discourse.itk.org/u/lorystays)\
**Replies:** 6\
**Last updated:** [September 29, 2019, 12:52pm UTC](https://discourse.itk.org/t/image-registration-using-mutual-information/1746 "2019-09-29T12:52:05Z")

</div>

Hi, i am trying to do image registration between 2 (natural scene) grayscale images using similarity transform and the mutual information similarity metric. I started by trying to repeat the results from the following…

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

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