Thank you for tying to help me.

Casting to the exact input image type is what I tryied to implement (after
checking it with the debugger).
Actually, I ran it again with these commands, but received the mentioned
error.

 typedef    unsigned short        InputPixelType;
 typedef     itk::Image    < InputPixelType,    3    >    InputImageType;
 itk::Image< InputPixelType, 3>::Pointer itkImage_1;

- I'd like to mention again that the error accepted in the following
command:
 myModulePointer->Update(); // a command at the file: MyPlugInView.cpp
- My application was generated by the CTK's generator and I just changed
that application in order to get a multiple number of input images (instead
of one input image, as the generator implemented).

On Wed, Nov 9, 2011 at 10:42 PM, Miklos Espak <[email protected]> wrote:

> Hi,
>
> are these 2D images?
>
> The itk::Image template class expects two parameters, the pixel type and
> the dimension. For the dimension there is a default value that is 2. That's
> why your code does not cause compile error.
>
> However, you must cast the mitk::Image into exactly the same kind of
> itk::Image. If you have a 3D mitk::Image, you cannot cast it into a 2D itk
> image. Even the pixel types must be the same.
>
> In your code:
>   itk::Image < ImageType > ::Pointer    itkImage_1;
>
> The ImageType name is rather misleading, since a primitive type should be
> there, typically.
>
> Best,
> Miklos
>
> On Wed, Nov 9, 2011 at 8:41 PM, Miri Trope <[email protected]> wrote:
>
>> Hi everyone,
>>
>> I manipulated the ability to select and manipulate four 3D input images
>> from a known type (all of them have the same type). I mean that the user
>> has to pick four images on mitk platform and run my module.
>> But it returns a run-time error which described below. That run time
>> returned after the command:
>> myModulePointer->Update();
>>
>> In addition below is my code, please help me to figure it out. It's just
>> my first time to manipulate things like that ...
>>
>> run time error
>> ==========
>> Unhandled exception at 0x7d4e237e in MyApp.exe: Microsoft C++ exception:
>> itk::ExceptionObject at memory location 0x00d9b640..
>> First-chance exception at 0x7d4e237e in MyApp.exe: Microsoft C++
>> exception: [rethrow] at memory location 0x00000000..
>> ==========
>>
>> MyPlugInView.cpp
>> -----------------
>> void MyPlugInView::DoImageProcessing()
>> {
>>   std::vector<mitk::DataNode*> nodes = this->GetDataManagerSelection();
>>   myModule::Pointer myModulePointer = myModule::New();
>>
>>   while(!nodes.empty()) // set the input images to const member pointers
>> of class MyModule
>>   {
>>     mitk::DataNode* node = nodes.back();
>>     nodes.pop_back();
>>     mitk::BaseData* data = node->GetData();
>>     mitk::Image* image = dynamic_cast<mitk::Image*>( data );
>>
>>     // I did the next assignment for each image by switching an index in
>> [N=1:numOfImages]
>>    // these assignments really work! each command assigns the input image
>> to her member pointer
>>     myModulePointer->SetinputImage_N(image);
>>     ...
>>   }
>>     myModulePointer->Update();// here I get the run time error
>> }
>>
>> MyModule.h
>> -------------
>> class MyModuleLib_EXPORT MyModule : public mitk::ImageToImageFilter
>> {
>> public:
>>   void MyFunction( mitk::Image::Pointer outputImage );
>>   // pointers to mitk selected input images
>>   mitk::Image::ConstPointer m_inputImage_1;
>>   mitk::Image::ConstPointer m_inputImage_2;
>>   mitk::Image::ConstPointer m_inputImage_3;
>>   mitk::Image::ConstPointer m_inputImage_4;
>>
>>   void GenerateData();
>>
>> protected:
>>   MyModule();
>>   ~MyModule();
>> };
>>
>> MyModule.cpp
>> ------------
>> void MyModule::MyFunction( mitk::Image::Pointer outputImage )
>> {
>>   itk::Image < ImageType > ::Pointer    itkImage_1;
>>   mitk::CastToItkImage(m_inputImage_1, itkImage_1); // in order to get
>> rid of the const pointer of mitk input image
>>   mitk::CastToMitkImage(itkImage_1, outputImage); // in order to view my
>> result
>> }
>>
>> MyModule::MyModule():
>> m_inputImage_1(0),m_inputImage_2(0),m_inputImage_3(0),m_inputImage_4(0)
>> {
>>   this->SetNumberOfInputs(4); // four selected inputImages
>> }
>>
>> MyModule::~MyModule()
>> {
>> }
>>
>> void MyModule::GenerateData()
>> {
>>     mitk::Image::Pointer outputImage = this->GetOutput();
>>     MyFunction( outputImage );
>> }
>>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> RSA(R) Conference 2012
>> Save $700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> mitk-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mitk-users
>>
>>
>
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to