[Insight-users] ImageSource->GetOutput() type

Benjamin King king . benjamin at mh-hannover . de
Thu, 28 Aug 2003 10:50:36 +0100


------------065IJz5Pgc4QrUW4IYQgb8
Content-Type: text/plain; charset=iso-8859-15; format=flowed

Hi all,

I want to wrap a part of my pipeline in a function, but I'm troubled by the 
difference between itk::Image::Pointer and itk::Image*.
My function looks like (also see the attached code):

  ImageType::Pointer someFunction(ImageType* image);

I chose the argument's type like that because according to the
documentation all itk::ImageSources return a plain pointer with
GetOutput(). The return value's type is used in accordance to a previous 
post by Bill (http://www . itk . org/pipermail/insight-users/2003- 
June/004124.html).

When I run the attached code, the image returned by someFunction
is an empty image, even after I Update()d it.

In a related context, I have functions like
  double returnSomeFeature(ImageType* image);
that work fine for filter outputs but not for "handcrafted" images:
  // Compiles
  double feature1 = returnSomeFeature(imageReader->GetOutput);

  // Doesn't compile
  ImageType::Pointer image = ImageType::New();
  image->SetLargetsPossibleRegion(....)
  image->SetBufferedRegion(....)
  image->Allocate(....)
  double feature2 = returnSomeFeature(image);
The attached code doesn't demonstrate this, but I guess the problems
are related in some way.

Can someone point out the problem or reproduce the error?


Best regards,
  Benjamin

-- 
Benjamin King
Institut für Medizinische Informatik
Medizinische Hochschule Hannover
Tel.: +49  511  532-2663
------------065IJz5Pgc4QrUW4IYQgb8
Content-Disposition: attachment;
	filename="DebugReturnValue.cpp"
Content-Type: application/octet-stream;
	name="DebugReturnValue.cpp"
Content-Transfer-Encoding: Base64

I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSAiaXRrVGhyZXNob2xkSW1h
Z2VGaWx0ZXIuaCIKI2luY2x1ZGUgIml0a1JhbmRvbUltYWdlU291cmNlLmgi
CiNpbmNsdWRlICJpdGtJbWFnZS5oIgoKLy8gVGhlIGZ1bmN0aW9uIHRha2Vz
IGEgcGxhaW4gcG9pbnRlciB0byBhbiBpbWFnZSBiZWNhdXNlIHRoYXQncyB3
aGF0Ci8vIGl0azo6SW1hZ2VTb3VyY2U6OkdldE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