Okay. I suppose your "ReaderType" typedef is actually a itk::ImageFileReader, is it?

Since you probably did something like

typedef itk::Image<unsigned char, 3> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;

you *already* know the image type at compile time. Hence you don't need to use any of MITK Access* macros (they are of use if you do not know the image type explicitly). Either just call your

void AddOffset(ImageType* image, ...)

function directly or if you have the corresponding MITK image (e.g. named "yourMitkImage") do something like

typedef mitk::ImageToItk<ImageType> ImageToItkType;
itk::SmartPointer<ImageToItkType> imagetoitk = ImageToItkType::New();
imagetoitk->SetInput(yourMitkImage);
imagetoitk->Update();
AddOffset(imagetoitk->GetOutput(), ...);

- Sascha

On 10/28/2011 07:23 PM, Miri Trope wrote:
Thank you for your answer.

I'm trying to achive the same as the readerFilter of ITK does:
   ReaderType::Pointer reader = ReaderType::New();
   reader->SetFileName( argv[1] );
in that way, you tell the compiler how to read the image (and avoid casting afterwards). But it seems that by the template on web (of awesomeFilter <https://github.com/MITK/MITK-ProjectTemplate/blob/master/Modules/MyAwesomeLib/AwesomeImageFilter.cpp>) the image can't be read in other type - if I'm trying to change the input image type of the function (line 25) void AddOffset(_*itk::Image<TPixel, VImageDimension*_*>** image, int offset, mitk::Image::Pointer outputImage)


like this:
void AddOffset(itk::Image <_*unsigned char, 3*_*>** image, int offset, mitk::Image::Pointer outputImage)


, it returns compilations errors (_before I insert a picture_) like I've mentioned.


Hope that now my problem is clearer.

On Fri, Oct 28, 2011 at 7:01 PM, Sascha Zelzer <[email protected] <mailto:[email protected]>> wrote:

    Hi,


    On 10/28/2011 12:23 PM, Miri Trope wrote:
    Hi All,

    I have some questions:

    1. The example of template on web (awesomeFilter) gets the image
    type as is by typename

    templaye<_*typename TPixel*_, unsigned int VImageDimension>
    void AddFilter(itk::Image<*_TPixel_*, VImageDimension>* image,
    mitk::Image::Pointer outputImage)
    {...}
     ,thus if I want to change the image type, I need to use the
    filter: itk::castingFilter. How can I get the image as any type
    that _I want_ and avoid the casting afterwards? My intuition is
    telling me that it should be something like that:
    typename<_*float**TPixel*_, unsigned int VImageDimension>
    but that returns errors...


    If you read an image from disk (e.g. by pressing "File->Open..."
    in the application menu), the loaded image has a specific pixel
    type (say, for example, "unsigned char"). So what are you trying
    to achieve? ITK filters can work with any type (usually).


    2. It's really necessary to add the cpp files in the cmake file:
    moduls\MyModuleLib\files.cmake like that:

    set (CPP_FILES
    myCppFile1.cpp
    myCppFile2.cpp)
    ...
    I think that when I don't add that, it doesn't matter the result.

    Yes, that is absolutely necessary (unless the files contain code
    which is not used anywhere - then there is no reason to add them
    at all, of course).

    Best,
    Sascha



------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to