[Insight-users] itkSpatialObjectToImageStatisticsCalculator problem

Benjamin King king . benjamin at mh-hannover . de
Mon, 11 Aug 2003 11:18:10 +0100


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

Hi Julien,

> Your code looks good.
> I think the problem comes from the spacing. Can you try to remove the 
> line:
>
>> ellipse->SetSpacing(imageReader->GetOutput()->GetSpacing());

indeed there was a problem with the spacing. It wasn't initialized when I 
called imageReader->GetOutput()->GetSpacing() because I didn't call 
imageReader->Update() before that.
But I'm afraid that my problem still isn't fixed. For a lot of parameters, 
I still get "-1.#IND 0" as output.
It doesn't help to remove the line either. Also I'd like to keep the 
spacing of the image and the ellipse consistent. It may not be obligatory, 
but it just makes me feel better =)

I clarified my code a bit, added some comments and fixed a misconception 
that I had about the meaning of spacing.
I also added some debugging code that writes an Analyze file (Debug.hdr + 
Debug.img) containing the sphere I intended to do statistics with. As my 
mailclient messed with the inlined code, this time I made it an attachment.

If you like, I can also send the anisotropic dataset (spacing 0.7, 0.7, 
2.0) and a list of parameters. That would be a 5MB zipfile.

Thanks for your help,
  Benjamin




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

I2luY2x1ZGUgIml0a0ltYWdlLmgiDQojaW5jbHVkZSAiaXRrSW1hZ2VGaWxl
UmVhZGVyLmgiDQojaW5jbHVkZSAiaXRrU3BhdGlhbE9iamVjdC5oIg0KI2lu
Y2x1ZGUgIml0a0VsbGlwc2VTcGF0aWFsT2JqZWN0LmgiDQojaW5jbHVkZSAi
aXRrU3BhdGlhbE9iamVjdFRvSW1hZ2VTdGF0aXN0aWNzQ2FsY3VsYXRvci5o
Ig0KI2luY2x1ZGUgIml0a0FmZmluZVRyYW5zZm9ybS5oIg0KI2lu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7DQogIGltYWdlV3JpdGVyLT5VcGRhdGUo
KTsNCg0KICByZXR1cm4gMDsNCn0NCg==
------------gx3jN7VRnCEODLqg66lYrZ
Content-Disposition: attachment;
	filename="CMakeLists.txt"
Content-Type: text/plain;
	name="CMakeLists.txt"

# This project is intended to be built outside the Insight source tree
PROJECT(volumestatistics)

# Find ITK.
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
  MESSAGE(FATAL_ERROR
          "Cannot build without ITK.  Please set ITK_DIR.")
ENDIF(ITK_FOUND)

ADD_EXECUTABLE(volumestatistics volumestatistics.cxx )

TARGET_LINK_LIBRARIES(volumestatistics ITKCommon ITKIO ITKBasicFilters)


------------gx3jN7VRnCEODLqg66lYrZ--