[Insight-users] Problem with ShiftScaleImageFilter

Harri Tapio Jaalinoja harri.jaalinoja@helsinki.fi
Fri, 15 Nov 2002 12:28:47 +0200 (EET)


Thanks Jim,

SetRegion() did the trick!

Cheers,
Harri


On Wed, 13 Nov 2002, Miller, James V (Research) wrote:

> Looking at your code, I think you need to call SetRegion() on the ImportImageFilter
> to inform the filter how many rows, columns, slices, etc. are in the image.
>
> Regions are defined by a start Index and a Size. The start Index can be
> zero.
>
> (Gotta run to a meeting, otherwise I'd write out the code for you....)
>
> Jim
>
>
>
> > -----Original Message-----
> > From: Harri Tapio Jaalinoja [mailto:hajaalin@cc.helsinki.fi]
> > Sent: Tuesday, November 12, 2002 8:21 AM
> > To: insight-users@public.kitware.com
> > Subject: [Insight-users] Problem with ShiftScaleImageFilter
> >
> >
> >
> > Hi folks,
> >
> > this is related to the ImportImageFilter issue I had earlier.
> > Some kind of an update problem seems to bother me also with
> > this filter,
> > which I want to place in the pipeline next to the ImportImageFilter.
> >
> > In short, the purpose of my excercise is to try and make a
> > little command
> > line tool of a single ITK filter. Read the image in using BSoft tools,
> > process, write output with a different name. As an example I chose the
> > ShiftScaleImageFilter, see attached bitkShiftScaleImageFilter.cxx.
> >
> > Now, thanks to Bill Lorensen, my import is ok:
> >   itk::ImportImageFilter<PixelType, 3>::Pointer breader =
> >     itk::ImportImageFilter<PixelType, 3>::New();
> >   breader->SetImportPointer(data ,num, false);
> >   breader->Update();
> >
> >   std::cerr << "Try to print a pixel from reader output..."
> > << std::endl;
> >   itk::Image<PixelType, 3>::Pointer image = breader->GetOutput();
> >   std::cerr << image->GetPixel(index) << std::endl;
> >   std::cerr << "OK" << std::endl;
> >
> > There are values in the breader->GetOutput() image.
> > ---
> > Try to print a pixel from reader output...
> > -0.160718
> > OK
> > ---
> >
> > The next step does not work:
> >   // Set up the filter
> >   itk::ShiftScaleImageFilter<ImageType, ImageType>::Pointer ssfilter
> >     = itk::ShiftScaleImageFilter<ImageType, ImageType>::New();
> >   ssfilter->SetInput(breader->GetOutput());
> >   ssfilter->SetShift(100);
> >   ssfilter->SetScale(-5);
> >   ssfilter->Update();
> > //   ssfilter->SetInput(img);
> >
> >   std::cerr << "Try to print a pixel from filter output..."
> > << std::endl;
> >   itk::Image<PixelType, 3>::Pointer image2 = ssfilter->GetOutput();
> >   std::cerr << image2->GetPixel(index) << std::endl;
> >   std::cerr << "OK" << std::endl;
> >
> > The output looks like this:
> > ---
> > Try to print a pixel from filter output...
> > 0
> > OK
> > ---
> >
> > so neither the shift nor the scale seems to have done its
> > job, despite the
> > Update(). If I remove the Update(), I get a segmentation fault.
> >
> > And as I mentioned earlier today, the third step, printing
> > out the data
> > does not work either, I just get an empty file.
> >
> > All the IO stuff in the code is basically copied from ITK
> > examples, via
> > my previous tests, which at least were able to output
> > something, so I'm at
> > loss as to what I might have missed here. Maybe you can spot
> > something?
> >
> > Thanks,
> >
> > Harri
> >
>