# How to use the GetScalesOutput() method in MultiscaleHessianBasedMeasureImageFilter

**URL:** <https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433>\
**Category:** Beginner Questions\
**Tags:** itk, python\
**Created:** [February 6, 2024, 9:12am UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433 "2024-02-06T09:12:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomo](https://discourse.itk.org/letter_avatar_proxy/v4/letter/t/54ee81/32.png) [@Tomo](https://discourse.itk.org/u/Tomo)\
**Post date:** [February 6, 2024, 9:12am UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433/1 "2024-02-06T09:12:07Z")

</div>

Hello,

I am interested in applying a vesselness filter process to MRA images, referencing “Antiga, L. (2007). Generalizing vesselness with respect to dimensionality and shape. The Insight Journal.” I have written a script using Python 3.11.2.

After obtaining `.GetScalesOutput()` to check the scale values where pixels showed the best response, I attempted to convert it into a numpy array using `itk.GetArrayFromImage`. However, I encounter an error at the `itk.GetArrayFromImage` step. Is there any suggestion for improvement?

Many thanks.

===============================  
multiScaleHessianFilter.Update()

output\_image = multiScaleHessianFilter.GetOutput()  
output\_image\_array = itk.GetArrayFromImage(output\_image)  
→No problem here

scales\_image = multiScaleHessianFilter.GetScalesOutput()  
scales\_image\_array = itk.GetArrayFromImage(scales\_image)

> > PyMemoryView\_FromBuffer(): info-\>buf must not be NULL

---

<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:** [February 6, 2024, 1:49pm UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433/2 "2024-02-06T13:49:42Z")

</div>

What does `print(scales_image)` shows? `ScalesOutput` should be a `float` image. Did you call `multiScaleHessianFilter.GenerateScalesOutputOn()` before `multiScaleHessianFilter.Update()`?

---

<div class="post-metadata">

**Author:** ![Tomo](https://discourse.itk.org/letter_avatar_proxy/v4/letter/t/54ee81/32.png) [@Tomo](https://discourse.itk.org/u/Tomo)\
**Post date:** [February 7, 2024, 1:15am UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433/3 "2024-02-07T01:15:03Z")

</div>

[dzenanz](https://discourse.itk.org/u/dzenanz),

Thank you for the guidance. print(scales\_image) shows itk.itkImagePython.itkImageF3. As you indicated, by inserting before .Update, I am now able to obtain the scale image.

Could you tell me more about how to adjust `sigma_min` and `sigma_max` based on the output from `multiScaleHessianFilter.GetScalesOutput()` ?

ChatGPT mentions, “It is possible to adjust `sigma_min` and `sigma_max` based on the information obtained from `multiScaleHessianFilter.GetScalesOutput()` . `GetScalesOutput()` provides the scale (`sigma` values) at which the filter showed the highest vesselness for each pixel. From this output, you can estimate the optimal range of scales for the vascular structures you wish to analyze. It was suggested to use the values at the smallest end of the scale distribution as a reference for adjusting `sigma_min` , and the values at the largest end of the scale distribution as a basis for adjusting `sigma_max` .”

 ![スクリーンショット 2024-02-07 10.19.22](https://discourse.itk.org/uploads/default/original/2X/8/89f5bef2cc9108f2adf75c1fd1036710189414a4.jpeg)

However, when analyzing the histogram of the scale values provided by GetScalesOutput(), I end up with minimum and maximum scale values that match my initial settings.  
 ![98671b87-63b5-469c-84f0-7d0c9cbf26f0](https://discourse.itk.org/uploads/default/original/2X/5/558b838346232450b198c9b59cb7d3ad54c79b86.png)

I have read various literature but still haven’t found clear guidance on setting sigma\_min and sigma\_max optimally.

---

<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:** [February 7, 2024, 2:38pm UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433/4 "2024-02-07T14:38:39Z")

</div>

Your `sigma_max` seems too big. You could also share the scales image. You did not say what you are trying to accomplish, so providing advice is not easy.

---

<div class="post-metadata">

**Author:** ![Tomo](https://discourse.itk.org/letter_avatar_proxy/v4/letter/t/54ee81/32.png) [@Tomo](https://discourse.itk.org/u/Tomo)\
**Post date:** [February 13, 2024, 3:40am UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433/5 "2024-02-13T03:40:34Z")

</div>

Thank you for your response, and I apologize for the delay.

My MRA images have been resampled to an isotropic resolution of 0.5mm. In terms of the thickest vessels, such as the internal carotid artery, which is about 4mm (approximately 8 voxels), and the thinnest vessels found on the surface of the brain, which are about 1mm (2 voxels), I am trying to enhance these using a vesselness filter. However, I am struggling to determine the optimal settings for sigma\_max and sigma\_min for this purpose. Ultimately, I plan to use the vesselness filter image as a feature image for level set segmentation.
