How to compute & plot hostogram of dicom images?

Hello,

I want to compute the histogram of dicom images and then plot that graph.

I tried to use the example from
https://itk.org/Doxygen/html/SphinxExamples_2src_2Numerics_2Statistics_2ComputeHistogramFromGrayscaleImage_2Code_8cxx-example.html

It gives me frequency values with number of bins of 256.
How to select number of bins for dicom image?

And how to plot it in graph? And then how to calculate thresholds from histogram, which I can use it later in Connected threshold image filter? Is it correct way to do segmentation?

Please help me.
Thanks in advance.

That is one way to do segmentation. Depending on your problem, it might or might not work. If you can’t tell in advance, you can try it and know for sure.

ITK does not do plotting. VTK can do it. Excel and LibreOffice Calc can do it if you write it into a CSV file.

Thanks for your reply.

I am trying to segment blood vessels of liver. And I want to use connected thresholding and for that I need thresholds.

I was thinking to take histogram and then from that I can calculate thresholds.
Because I don’t know how to select threshold values in filter. Is it same like CT value(HU value)?

Could you please tell me, will this work and/or any different way to achieve it? And is there any other way to calculate & plot histogram in VTK?
And how can I compute histogram of dicom series?

Please help me.

Hello @Pooja_Virkar,

itkwidgets may be of interest. Every image visualization includes an interactive histogram, which makes it extremely easy to understand threshold values, etc.

To read and view a DICOM series, e.g.

import itk
from glob import glob
from itkwidgets import view

series = glob('dicom_series_folder/*.dcm')
series.sort()
image = itk.imread(series)
view(image)
1 Like

Hello,

The solution you provided i.e. itkwidgets is with python.

But I am using ITK and VTK in c++.
So Is there any other way to get histogram of complete dicom series using ITK or VTK in C++? And then use it to select thresholds?

ITK has around a dozen of filters that will automatically select a threshold based on the image’s intensity histogram:

https://itk.org/Doxygen/html/group__ITKThresholding.html