[vtkusers] why my computing gray scale histogram of DICOM files is different from mimics

Liu_tj tjlp at netease.com
Sun Aug 14 21:46:39 EDT 2016

Hi, David,

Thanks for your point.

I understand the plot shift. It just change the gray scale value range from [-1023, 2016] to [0, 3140]. This does not impact the generated graph shape.

Would you like to explain how to show log plot according to my code?


Liu Peng

在2016-08-15,"David Gobbi" <david.gobbi at gmail.com> 写道: -----原始邮件-----
发件人:"David Gobbi" <david.gobbi at gmail.com>
发送时间:2016年08月15日 星期一
收件人:"Liu_tj" <tjlp at netease.com>
抄送:"vtkusers" <vtkusers at vtk.org>
主题:Re: [vtkusers] why my computing gray scale histogram of DICOM files is different from mimics

Two differences:

1) MIMICS is showing a log plot
2) The plot is shifted by the RescaleIntercept

On Sun, Aug 14, 2016 at 9:52 AM, Liu_tj <tjlp at netease.com> wrote:


I try to get the grayscale of points in DICOM files and draw the histogram using .NET component, and what I get is different from the histogram of MIMICS. My C# code is as follow, the returned vtkLongArray stores the grayscale statistic result, value of element is the total number of the point whose gray scale value is equal to the array index:

public vtkLongArray GetGreyScaleStatisticsFromImageData(vtkImageData data, out long min_grey, out long max_grey)
            vtkImageExtractComponents extract = vtkImageExtractComponents.New();

            double[] scalarrange = extract.GetOutput().GetScalarRange();
            min_grey = (long)scalarrange[0];
            max_grey = (long)scalarrange[1];
            long size = (long)(scalarrange[1] - scalarrange[0]);
            vtkImageAccumulate histogram = vtkImageAccumulate.New();
            histogram.SetComponentExtent((int)min_grey, (int)max_grey, 0, 0, 0, 0);
            histogram.SetComponentOrigin(0, 0, 0);
            histogram.SetComponentSpacing(1, 0, 0);
            vtkLongArray count = vtkLongArray.New();
            IntPtr value = histogram.GetOutput().GetScalarPointer();
            string scalartype = histogram.GetOutput().GetScalarTypeAsString();
            int s = histogram.GetOutput().GetScalarSize();
            long[] managedValArray = new long[size];
            Marshal.Copy(value, managedValArray, 0, managedValArray.Length);
            for(int i=0; i<managedValArray.Length; i++)
                count.SetTuple1(i, managedValArray[i]);
            return count;

The images of my and MIMICS are attached.

Does any guys know that?

Liu Peng

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160815/cbdda850/attachment.html>

More information about the vtkusers mailing list