[vtkusers] why my computing gray scale histogram of DICOM files is different from mimics
Liu_tj
tjlp at netease.com
Mon Aug 15 09:41:37 EDT 2016
Hi,David,
I try the log plot. It is more similar to MIMICS. However, it is not smooth yet.
Refer to the attachment for the graph.
Any suggestions?
Thanks.
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: Re: [vtkusers] why my computing gray scale histogram of DICOM files is different from mimics
Hi Liu Peng,
Take the log of count. Or log of count+1, to avoid log(0).
It will probably be like this:
for(int i=0; i<managedValArray.Length; i++)
{
count.SetTuple1(i, log(1 + managedValArray[i]));
}
- David
On Sun, Aug 14, 2016 at 7:46 PM, Liu_tj <tjlp at netease.com> wrote:
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?
Thanks
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:
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/20160815/40b1020a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Better-histogram.png
Type: image/png
Size: 9060 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160815/40b1020a/attachment-0001.png>
More information about the vtkusers
mailing list