[vtkusers] why my computing gray scale histogram of DICOM files is different from mimics
David Gobbi
david.gobbi at gmail.com
Sun Aug 14 12:47:56 EDT 2016
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:
> Hi,
>
> 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();
> extract.SetInputData(data);
> extract.SetComponents(0);
> extract.Update();
>
> 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.SetInputConnection(extract.GetOutputPort());
> histogram.SetComponentExtent((int)min_grey, (int)max_grey, 0,
> 0, 0, 0);
> histogram.SetComponentOrigin(0, 0, 0);
> histogram.SetComponentSpacing(1, 0, 0);
> histogram.SetIgnoreZero(1);
> histogram.Update();
> vtkLongArray count = vtkLongArray.New();
> count.SetNumberOfComponents(1);
> count.SetNumberOfTuples(size);
> 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?
>
> Thanks
> Liu Peng
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160814/f7323d84/attachment.html>
More information about the vtkusers
mailing list