[Insight-developers] image information reset by gradient magnitude filter

Bill Lorensen bill.lorensen at gmail.com
Thu Feb 5 10:08:32 EST 2009


Luis,

I was able to reproduce the problem. Now it is fixed.

Bill

On Thu, Feb 5, 2009 at 10:05 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
> Hi Richard,
>
> Thanks for the report.
>
> I couldn't replicate your observation with my build of ITK 3.10.
>
> When running the example:
>
>    GradientMagnitudeRecursiveGaussianImageFilter.cxx
>
> on an image with non-trivial spacing and origin,
> I still get that origin and spacing on the output.
>
>
> BTW: Why are you calling Update() in the output of the filter
>     instead of calling Update() on the filter itself ?
>
>
> I see that Bill added a test for this issue today,
> and committed a change to the filter.
>
>
> Please let us know if that made a difference.
>
>
>   Thanks
>
>
>      Luis
>
>
> -----------------------
> Richard Beare wrote:
>>
>> Hi,
>> I've come across a strange resetting of image information when using
>> the gradient magnitude filter (code below). All spacing and
>> orientation information seems to have been reset to default values.
>> This is using itk 3.10.1 retrieved using the cvs repository, and the
>> cvs head from about 2 weeks ago under linux. I haven't yet checked any
>> other filters to see if the problem is more general.
>>
>> nifti file report from fslhd of input image:
>>
>> sizeof_hdr     348
>> data_type      INT16
>> dim0           3
>> dim1           256
>> dim2           120
>> dim3           256
>> dim4           1
>> dim5           1
>> dim6           1
>> dim7           1
>> vox_units      mm
>> time_units     Unknown
>> datatype       4
>> nbyper         2
>> bitpix         16
>> pixdim0        0.0000000000
>> pixdim1        0.8203120232
>> pixdim2        1.1999969482
>> pixdim3        0.8203120232
>> pixdim4        0.0000000000
>> pixdim5        0.0000000000
>> pixdim6        0.0000000000
>> pixdim7        0.0000000000
>> vox_offset     352
>> cal_max        0.0000
>> cal_min        0.0000
>> scl_slope      1.000000
>> scl_inter      0.000000
>> phase_dim      0
>> freq_dim       0
>> slice_dim      0
>> slice_name     Unknown
>> slice_code     0
>> slice_start    0
>> slice_end      0
>> slice_duration 0.000000
>> time_offset    0.000000
>> intent         Unknown
>> intent_code    0
>> intent_name
>> intent_p1      0.000000
>> intent_p2      0.000000
>> intent_p3      0.000000
>> qform_name     Aligned Anat
>> qform_code     2
>> qto_xyz:1      -0.820312  -0.000000  -0.000000  105.000000
>> qto_xyz:2      0.000000  1.199997  -0.000000  -74.299637
>> qto_xyz:3      -0.000000  0.000000  0.820312  -114.179565
>> qto_xyz:4      0.000000  0.000000  0.000000  1.000000
>> qform_xorient  Right-to-Left
>> qform_yorient  Posterior-to-Anterior
>> qform_zorient  Inferior-to-Superior
>> sform_name     Scanner Anat
>> sform_code     1
>> sto_xyz:1      -0.820312  -0.000000  0.000000  105.000000
>> sto_xyz:2      -0.000000  1.199997  -0.000000  -74.299637
>> sto_xyz:3      0.000000  0.000000  0.820312  -114.179565
>> sto_xyz:4      0.000000  0.000000  0.000000  1.000000
>> sform_xorient  Right-to-Left
>> sform_yorient  Posterior-to-Anterior
>> sform_zorient  Inferior-to-Superior
>> file_type      NIFTI-1+
>> file_code      1
>> descrip
>> aux_file
>>
>> Result image:
>> sizeof_hdr     348
>> data_type      INT16
>> dim0           3
>> dim1           256
>> dim2           120
>> dim3           256
>> dim4           1
>> dim5           1
>> dim6           1
>> dim7           1
>> vox_units      mm
>> time_units     Unknown
>> datatype       4
>> nbyper         2
>> bitpix         16
>> pixdim0        0.0000000000
>> pixdim1        1.0000000000
>> pixdim2        1.0000000000
>> pixdim3        1.0000000000
>> pixdim4        0.0000000000
>> pixdim5        0.0000000000
>> pixdim6        0.0000000000
>> pixdim7        0.0000000000
>> vox_offset     352
>> cal_max        0.0000
>> cal_min        0.0000
>> scl_slope      1.000000
>> scl_inter      0.000000
>> phase_dim      0
>> freq_dim       0
>> slice_dim      0
>> slice_name     Unknown
>> slice_code     0
>> slice_start    0
>> slice_end      0
>> slice_duration 0.000000
>> time_offset    0.000000
>> intent         Unknown
>> intent_code    0
>> intent_name
>> intent_p1      0.000000
>> intent_p2      0.000000
>> intent_p3      0.000000
>> qform_name     Aligned Anat
>> qform_code     2
>> qto_xyz:1      -1.000000  0.000000  0.000000  -0.000000
>> qto_xyz:2      0.000000  -1.000000  0.000000  -0.000000
>> qto_xyz:3      0.000000  0.000000  1.000000  0.000000
>> qto_xyz:4      0.000000  0.000000  0.000000  1.000000
>> qform_xorient  Right-to-Left
>> qform_yorient  Anterior-to-Posterior
>> qform_zorient  Inferior-to-Superior
>> sform_name     Scanner Anat
>> sform_code     1
>> sto_xyz:1      -1.000000  0.000000  0.000000  -0.000000
>> sto_xyz:2      0.000000  -1.000000  0.000000  -0.000000
>> sto_xyz:3      0.000000  0.000000  1.000000  0.000000
>> sto_xyz:4      0.000000  0.000000  0.000000  1.000000
>> sform_xorient  Right-to-Left
>> sform_yorient  Anterior-to-Posterior
>> sform_zorient  Inferior-to-Superior
>> file_type      NIFTI-1+
>> file_code      1
>> descrip
>> aux_file
>>
>> Code:
>>
>> #include <itkGradientMagnitudeRecursiveGaussianImageFilter.h>
>> #include <itkImageFileWriter.h>
>> #include <itkImageFileReader.h>
>>
>>
>> template <class TImage>
>> void writeIm(typename TImage::Pointer Im, std::string filename)
>> {
>>  typedef typename itk::ImageFileWriter<TImage> WriterType;
>>  typename WriterType::Pointer writer = WriterType::New();
>>  writer->SetInput(Im);
>>  writer->SetFileName(filename.c_str());
>>  writer->Update();
>> }
>>
>> template <class TImage>
>> typename TImage::Pointer readIm(std::string filename)
>> {
>>  typedef typename itk::ImageFileReader<TImage> ReaderType;
>>  typename ReaderType::Pointer reader = ReaderType::New();
>>  reader->SetFileName(filename.c_str());
>>  typename TImage::Pointer result = reader->GetOutput();
>>  try
>>    {
>>    result->Update();
>>    }
>>  catch(itk::ExceptionObject &ex)
>>    {
>>    std::cout << ex << std::endl;
>>    std::cout << filename << std::endl;
>>    return 0;
>>    }
>>    result->DisconnectPipeline();
>>    return(result);
>> }
>>
>> int main(int argc, char * argv[])
>> {
>>
>>  const int dim = 3;
>>  typedef short PixType;
>>  typedef itk::Image<PixType, dim> RawImType;
>>
>>  typedef
>> itk::GradientMagnitudeRecursiveGaussianImageFilter<RawImType,RawImType>
>> GradFiltType;
>>
>>  RawImType::Pointer raw;
>>  RawImType::Pointer grad;
>>
>>  raw = readIm<RawImType>(argv[1]);
>>  GradFiltType::Pointer gradfilt = GradFiltType::New();
>>
>>  gradfilt->SetInput(raw);
>>  gradfilt->SetSigma(0.01);
>>  grad = gradfilt->GetOutput();
>>  grad->Update();
>>  grad->DisconnectPipeline();
>>  std::cout << raw->GetSpacing() << grad->GetSpacing() << std::endl;
>>  writeIm<RawImType>(grad, "grad.nii.gz");
>>
>>  return (EXIT_SUCCESS);
>> }
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>


More information about the Insight-developers mailing list