Thanks to Miklos for helping me out!
Finally, in the morning hours :-) I figure out my problem and succeed to
input a multiple number of images!
my mistake was in the file myPlugInView.cpp

I simply added the command:
myFilter->SetInput(image);

and it works perfectly!

before of that, I didn't realize that the command:
myFilter->setMacro(image);
isn't good, because the software doesn't understand that setMacro is
actually setting an input image which it needs (although this SetMacro is
an image).

Thus, the software needs exactly the right command: SetInput(image).

On Fri, Nov 11, 2011 at 10:20 PM, Miri Trope <[email protected]> wrote:

> Hi Miklos,
>
> Regarding your suggestion to set my input image by SetInput(...), and get
> the same error ...
> In order to be clear, I insert again the important parts of my code,
> including some changes according to your suggestion.
>
> void myModule::GenerateData()
> {
> mitk::Image::ConstPointer image = this->GetInput(0);
>
> mitk::ImagePointer outputImage = this->GetOutput();
>
> AccessIntegralPixelTypeByItk_n(image, MyFunction, (m_inputVal1,
> m_inputVal2, outputImage))
> }
>
> The following function manipulates some itk's filters on the (four) input
> images:
>
> template < typename TPixel, unsigned int VImageDimension >
>
> void myModule::MyFunction ( itk::Image <TPixel, VImageDimension>* image,
> int val1, int val2, mitk::Image::Pointer outputImage)
> {
> typedef itk::Image <TPixel, VImageDimension> ImageType;
>
> ImageType::Pointer itkImage_1;
> // I did that to all of the N images
>
> mitk::CastToImage ( m_inputImage_1, itkImage_1);
> // I did that to all of the N images
>
> mitk::CastMitkImage ( itkImage_1, outputImage);
> }
>
> myModule.h
> =========
>
> class myModule : public mitk:ImageToImageFilter
> {
> public:
>
>   template<typename TPixel, unsigned int VImageDimension>
>
>  void MyFunction (itk::Image<TPixel, VImageDimension>* inputImage, int,
> int, mitk::Image::Pointer outputImage)
>
>
>   mitk::Image::ConstPointer m_inputImage_1;
>
>   mitk::Image::ConstPointer m_inputImage_2;
>
>   mitk::Image::ConstPointer m_inputImage_3;
>
>   mitk::Image::ConstPointer m_inputImage_4;
>
> etc ...
>
> }
> On Fri, Nov 11, 2011 at 6:48 PM, Miklos Espak <[email protected]> wrote:
>
>> For your first question:
>>
>> you have not set the input image of your filter by SetInput(...)
>>
>> Miklos
>>
>> On Fri, Nov 11, 2011 at 5:32 PM, Miri Trope <[email protected]> wrote:
>> > Hi Miklos,
>> >
>> > My Exception is:
>> >
>> "..\..\..\CMakeExternals\Source\ITK\Code\Common\itkProcessObject.cxx:981:
>> > itk::ERROR: myModule:(18F41FB8): At least 1 inputs are required but
>> only 0
>> > are specified"
>> >
>> > In the output from Debug of visual studio:
>> > ERROR: In
>> //\//\CMakeExternals\Source\VTK\Rendering\vtkPolyDataMapper.cxx,
>> > line 60 vtkPaintPolyDataMapper (18F4D168) : Mapper has no input
>> >
>> > ERROR: In
>> //\//\CMakeExternals\Source\VTK\Rendering\vtkOpenGLTexture.cxx,
>> > line 196 vtkOpenGLTexture (188432F0): No scalar value found for texture
>> > input!
>> >
>> > what might be the reason for that run time error?
>> >
>> > * another conversion question which can save my time: I have a pointer
>> to a
>> > mitk::surface data and would like to view that surface on mitk. I might
>> need
>> > to convert that surface to an mitk::image. how should I do this?
>> >
>> >
>> > Thanks,
>> > Miri
>> > On Thu, Nov 10, 2011 at 11:48 AM, Miklos Espak <[email protected]>
>> wrote:
>> >>
>> >> Hi Miri,
>> >> in your original e-mail there was this line:
>> >>    itk::Image < ImageType > ::Pointer    itkImage_1;
>> >>
>> >> now there is these lines:
>> >>
>> >>  typedef    unsigned short        InputPixelType;
>> >>  typedef     itk::Image    < InputPixelType,    3    >
>> InputImageType;
>> >>  itk::Image< InputPixelType, 3>::Pointer itkImage_1;
>> >>
>> >> These are different. In the first case you have a 2D image, in the
>> second
>> >> case 3D.
>> >> If the exception is thrown by the Update() function, it means that it
>> is
>> >> thrown by the filter's GenerateData function (or from its call
>> chain). So, I
>> >> still think that there is a type mismatch during the cast.
>> >> I suggest to put the Update call into an exception handler, catch
>> >> itk::ExceptionObject, and print its message. (As I remember, it is the
>> >> what() function that tells it to you.)
>> >> Best,
>> >> Miklos
>> >> On Thu, Nov 10, 2011 at 9:35 AM, Miri Trope <[email protected]>
>> wrote:
>> >>>
>> >>> 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