[Insight-users] Re: Wondering if it is a bug in Danielsson distance map filter

Luis Ibanez luis.ibanez at kitware.com
Thu, 15 Apr 2004 22:02:06 -0400


Hi Radhika,

Thanks for letting us know.

This is definitely a bug.

It has been entered as Bug # 755
http://www.itk.org/Bug/bug.php?op=show&bugid=755&pos=17


Regards,


    Luis



-------------------------------
Radhika Sivaramakrishna wrote:
> Hi Luis,
> The pixel type is unsigned char for everything.
> Radhika
> 
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
> Sent: Thursday, April 15, 2004 4:39 PM
> To: Radhika Sivaramakrishna
> Cc: ITK
> Subject: Re: Wondering if it is a bug in Danielsson distance map filter
> 
> 
> 
> Hi Radhika,
> 
> Thanks for posting this detailed report.
> 
> This looks like a bug...
> 
> Just a question... what is the pixel type that you
> use as output for the ShiftScale image ?
> 
> I'm wondering that if it is a float pixel type, we
> may be dealing with a pixel that has a float value
> very close to zero in the image passed as input
> to the Danielsson filter.
> 
> 
> Please let us know,
> 
> 
> 
>    Thanks
> 
> 
> 
> -----------------------------
> Radhika Sivaramakrishna wrote:
> 
>  > Hi Luis,
>  > I am observing a strange behavior in the Danielsson map filter and I am
>  > wondering if it is a bug. I have been experimenting with this for a few
>  > days now and I have found this behavior even on 3D images. I have
>  > attached an image (Mask_2D.img) that I ran the distance map filter on. I
>  > inverted this mask before running the filter. I ran it with and without
>  > setting UseImageSpacing. When I do not
>  >
>  > set UseImageSpacing, I observe some strange behavior. It sets 1 in
>  > places where it should not. Could you explain what is happening? My
>  > pixel type is unsigned char. Here is a very small portion of the code
>  > that just runs the shiftscale and Danielsson Filter. In the attached
>  > results you will clearly see an extra 1 in location (8,18) which should
>  > not be. I don't know if I am using this incorrectly or something else is
>  > happening.
>  >
>  > Thanks
>  > Radhika
>  >
>  > typedef itk::Image<PixelType,2> ImageType2D;
>  > typedef itk::ImageFileWriter< ImageType2D >  WriterType2D;    
>  > typedef itk::ShiftScaleImageFilter <ImageType2D, ImageType2D>
>  > ShiftScaleFilterType2D;
>  > typedef itk::DanielssonDistanceMapImageFilter <ImageType2D, ImageType2D>
>  > EDMFilterType2D;       EDMFilterType2D::Pointer edmfilter2D =
>  > EDMFilterType2D::New();
>  >
>  > ShiftScaleFilterType2D::Pointer ssfilter2D = 
> ShiftScaleFilterType2D::New();
>  >       
>  > ssfilter2D->SetShift(shift);
>  > ssfilter2D->SetScale(scale);
>  > edmfilter2D->SetInputIsBinary(true);
>  > //      edmfilter2D->SetUseImageSpacing(true);
>  > ssfilter2D->SetInput(mask);
>  > edmfilter2D->SetInput(ssfilter2D->GetOutput());
>  > edmfilter2D->Update();
>  >
>  > -----Original Message-----
>  > From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
>  > Sent: Wednesday, April 14, 2004 1:13 PM
>  > To: Radhika Sivaramakrishna
>  > Cc: ITK
>  > Subject: Re: [Insight-users] More questions on Daniellson distance map
>  > filter
>  >
>  >
>  > Hi Radhika,
>  >
>  > The DanielssonDistanceMap takes into account diagonal distances
>  > regardless of whether the UseImageSpacing flag is enabled or not.
>  >
>  > What changes when the flag is enabled is that the components
>  > of the pixel spacing are taken into account. Therefore the
>  > distances are reported in physical units (e.g. millimeters)
>  > instead of pixels.  As a consequence, enabling the flag also
>  > takes care of taking pixel anisotropy into account.
>  >
>  > The distances are computed as Euclidean distances, not as
>  > Manhattan distances (city-block), but are limited in precision
>  > to one-pixel. That is, there is no sub-pixel accuracy in the
>  > distance values.  An easy way to verify the Euclidean-ness of
>  > the resulting DistanceMap is to create a dataset with a single
>  > pixel on in the middle and pass it as input to the Danielsson
>  > DistanceMap filter.
>  >
>  > Using the DanielssonDistanceMap plugin for VolView would
>  > be a very easy way of experimenting with the distances.
>  >
>  >
>  > Please let us know if you have further questions.
>  >
>  >
>  >    Thanks
>  >
>  >
>  >      Luis
>  >
>  >
>  >
>  > -----------------------------
>  > Radhika Sivaramakrishna wrote:
>  >
>  >  > Hi Luis,
>  >  > Thanks for your explanation. I have a doubt: when the 
> UseImageSpacing is
>  >  > enabled, does this (1) take into account diagonal distances and (2)
>  >  > nonisotropic voxels also? I thought it did both. If I want to just 
> make
>  >  > sure that diagonal distances are taken into account (ie I don't 
> want to
>  >  > do city block distances or chessboard distances), but do not want to
>  >  > take non-isotropy into account, what should I do?
>  >  >
>  >  > Hope my question is clear.
>  >  > Thanks
>  >  > Radhika
>  >  >
>  >  >
>  >  >
>  >  > -----Original Message-----
>  >  > From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
>  >  > Sent: Monday, April 12, 2004 6:46 PM
>  >  > To: Radhika Sivaramakrishna
>  >  > Cc: ITK
>  >  > Subject: Re: [Insight-users] More questions on Daniellson distance 
> map
>  >  > filter
>  >  >
>  >  >
>  >  >
>  >  > Hi Radhika,
>  >  >
>  >  > When you enable the "UseImageSpacing" flag, the values
>  >  > of pixel spacing are used in the last stage of distance
>  >  > computation. The spacing is used to multiply the distance
>  >  > components when their squares are summed up.
>  >  >
>  >  > The resulting distance is then casted to the type of the
>  >  > output image pixel type. This is done in the file:
>  >  >
>  >  >      Insight/Code/BasicFilters/
>  >  >        itkDanielssonDistanceMapImageFilter.txx:
>  >  >
>  >  > in line 299:
>  >  >
>  >  >     dt.Set(
>  >  >       static_cast<
>  >  >          typename
>  >  >            OutputImageType::PixelType>(sqrt( distance )) );
>  >  >
>  >  >
>  >  > Note that the casting is done as a flat truncation.
>  >  > No effort is made for scaling the distances in the
>  >  > range of the pixel type.  Depending on the physical
>  >  > extent of your image, this may or may not be a problem.
>  >  >
>  >  >
>  >  >
>  >  > If you want to compute this distance scaling in a better
>  >  > way, you could setup the output pixel type as float,
>  >  > and then connect the output of the DanielssonDistanceMap
>  >  > filter to a RescaleIntensityImageFilter with output pixel
>  >  > type = unsigned char.  This last filter will then rescale
>  >  > nicely the distances into the range of intensities of the
>  >  > output image. Note that with this filter you can select
>  >  > what values to use for representing the maximum and minimum
>  >  > values of the distance.
>  >  >
>  >  >
>  >  > --
>  >  >
>  >  > You may want to take a look at the new VolView plugin
>  >  > for computing the Danielsson distance. The source code
>  >  > for this plugin is available at
>  >  >
>  >  >
>  >  >        InsightApplications/
>  >  >                 VolviewPlugins/
>  >  >                    vvITKDanielssonDistanceMap.cxx
>  >  >
>  >  >
>  >  >
>  >  >
>  >  > Please let us know if you have further questions,
>  >  >
>  >  >
>  >  > Thanks
>  >  >
>  >  >
>  >  >    Luis
>  >  >
>  >  >
>  >  >
>  >  > -------------------------------
>  >  >
>  >  > Radhika Sivaramakrishna wrote:
>  >  >
>  >  >  > Hi,
>  >  >  >
>  >  >  > I had more questions on the Danielsson distance map filter. I have
>  > set
>  >  >  > the input and output of the filter to unsigned char.
>  >  >  >
>  >  >  > I have also put the SetUseImageSpacing flag to true. This means 
> that
>  >  >  > actual distances may be computed which are more floating point
>  >  >  >
>  >  >  > numbers.  Since I am forcing the output to unsigned char, then
>  > does this
>  >  >  > mean that the actual distances are truncated to unsigned char
>  >  >  >
>  >  >  > or are they rounded to it? Is there a better way to handle this?
>  >  >  >
>  >  >  > Thanks
>  >  >  >
>  >  >  > Radhika
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  > -----------------------------------------------------
>  >  >  >
>  >  >  > Confidentiality Notice.
>  >  >  >
>  >  >  > This email message is for the sole use of the intended
>  > recipient(s) and
>  >  >  > may contain confidential and privileged information. Any 
> unauthorized
>  >  >  > review, use, disclosure or distribution is prohibited. If you 
> are not
>  >  >  > the intended recipient, please contact the sender by reply 
> email and
>  >  >  > destroy all copies of the original message. If you are the 
> intended
>  >  >  > recipient, please be advised that the content of this message is
>  > subject
>  >  >  > to access, review and disclosure by the sender's Email System
>  >  > Administrator.
>  >  >  >
>  >  >
>  >  >
>  >  >                                                   
>  >  > -----------------------------------------------------
>  >  > Confidentiality Notice.
>  >  > This email message is for the sole use of the intended 
> recipient(s) and
>  >  > may contain confidential and privileged information. Any unauthorized
>  >  > review, use, disclosure or distribution is prohibited. If you are not
>  >  > the intended recipient, please contact the sender by reply email and
>  >  > destroy all copies of the original message. If you are the intended
>  >  > recipient, please be advised that the content of this message is 
> subject
>  >  > to access, review and disclosure by the sender's Email System
>  > Administrator.
>  >  >
>  >
>  >
>  >                                                    
>  > -----------------------------------------------------
>  > Confidentiality Notice.
>  > This email message is for the sole use of the intended recipient(s) and
>  > may contain confidential and privileged information. Any unauthorized
>  > review, use, disclosure or distribution is prohibited. If you are not
>  > the intended recipient, please contact the sender by reply email and
>  > destroy all copies of the original message. If you are the intended
>  > recipient, please be advised that the content of this message is subject
>  > to access, review and disclosure by the sender's Email System 
> Administrator.
>  >
>  >           
>  >
>  > 
>  >
> 
> 
>                                                     
> ----------------------------------------------------- 
> Confidentiality Notice.
> This email message is for the sole use of the intended recipient(s) and 
> may contain confidential and privileged information. Any unauthorized 
> review, use, disclosure or distribution is prohibited. If you are not 
> the intended recipient, please contact the sender by reply email and 
> destroy all copies of the original message. If you are the intended 
> recipient, please be advised that the content of this message is subject 
> to access, review and disclosure by the sender's Email System Administrator.
>