[Insight-users] Problem with ShiftScaleImageFilter
Harri Tapio Jaalinoja
harri.jaalinoja@helsinki.fi
Tue, 12 Nov 2002 15:21:27 +0200 (EET)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
--0-1870838566-1037106531=:20163
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.OSF.4.30.0211121509301.20163@sirppi.helsinki.fi>
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
--0-1870838566-1037106531=:20163
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="bitkShiftScale.cxx"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.OSF.4.30.0211121508510.20163@sirppi.helsinki.fi>
Content-Description:
Content-Disposition: ATTACHMENT; FILENAME="bitkShiftScale.cxx"
Lyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQoNCiAgUHJvZ3JhbTog
ICBJbnNpZ2h0IFNlZ21lbnRhdGlvbiAmIFJlZ2lzdHJhdGlvbiBUb29sa2l0
DQogIE1vZHVsZTogICAgJFJDU2ZpbGU6IGl0a1dhdGVyc2hlZFNlZ21lbnRh
dGlvbkV4YW1wbGUuY3h4LHYgJA0KICBMYW5ndWFnZTogIEMrKw0KICBEYXRl
OiAgICAgICREYXRlOiAyMDAyLzA4LzI1IDE1OjUyOjExICQNCiAgVmVyc2lv
bjogICAkUmV2aXNpb246IDEuOSAkDQoNCiAgQ29weXJpZ2h0IChjKSAyMDAy
IEluc2lnaHQgQ29uc29ydGl1bS4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCiAg
U2VlIElUS0NvcHlyaWdodC50eHQgb3IgaHR0cDovL3d3dy5pdGsub3JnL0hU
TUwvQ29weXJpZ2h0Lmh0bSBmb3IgZGV0YWlscy4NCg0KICAgICBUaGlzIHNv
ZnR3YXJlIGlzIGRpc3RyaWJ1dGVkIFdJVEhPVVQgQU5ZIFdBUlJBTlRZOyB3
aXRob3V0IGV2ZW4gDQogICAgIHRoZSBpbXBsaWVkIHdhcnJhbnR5IG9mIE1F
UkNIQU5UQUJJTElUWSBvciBGSVRORVNTIEZPUiBBIFBBUlRJQ1VMQVIgDQog
ICAgIFBVUlBPU0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