[Insight-users] Re: How to make COM wrapper for ITK

Luis Ibanez luis.ibanez at kitware.com
Mon Jan 15 10:43:00 EST 2007


Hi Gopal

You can modify ImageEntropy1 to write its output in text file.

Just add the following code in line 270 of ImageEntropy1.cxx


   std::ofstream outputFile;
   outputFile.open("entropyValue.txt");
   outputFile << Entropy << std::endl;
   outputFile.close();


Then from your .NET program you could open the "entropyValue.txt"
file and read the Entropy value.

The code in your .NET program should look very similar:

   double Entropy;
   std::ifstream inputFile;
   inputFile.open("entropyValue.txt");
   inputFile >> Entropy;
   inputFile.close();



Regards,


   Luis


----------------------
Gopal Karemore wrote:
> Hi Luis!
> 
> Thanks for quick answer. But Execv wont work in C#.NET,  I tried with 
> Process.Start(Exe of ITK, Required Parameter), it worked very well but 
> my requirment is like that....
> 
> 1. GUI is in C#.NET 2003
> 2. I have built ITK on VC++ 6.0
> 3. I want ITK to utilize only ImageEntropy1.exe to calculate Entropy of 
> image.So i will Call EXE from C#.NET using Process.Start method.
> 4 Now I want after processing , ITK should give me Variable Entropy to 
> C#.NET, I dont want it on separate command window.
> 5. I think , Any means if you tell me how to write text file and write 
> calculated variable into it in ITK, I would be thankfull.
> 
> Main Question: How to write an Evaluated Variable into text file on the 
> disc so that any other program(Not ITK) can utilize it by reading that 
> text file.
> 
> Thanking you
> 
> 
> Regards
> K.Gopal
> 
> ///////////////////////////////////////////////
> Philips Medical System - Ultrasound
> Philips Innovation Campus
> Manyata Tech Park, Nagavara
> Bangalore - 560045
> 
> Tel : +91-80-4189 0000 Extn: 1329
> Mob: +91-9900216886
> Website: www.goops.9k.com
> ///////////////////////////////////////////////
> ----- Original Message ----- From: "Luis Ibanez" <luis.ibanez at kitware.com>
> To: "Gopal Karemore" <gopalrk at blr.pin.philips.com>
> Sent: 2007 Jan 05 11:31 PM
> Subject: Re: How to make COM wrapper for ITK
> 
> 
>>
>> Hi Gopal,
>>
>> One way of invoking an executable is to simply use the "system" call,
>> or the "execv" calls. The difference between the multiple variations
>> of this calls is whether you block your application while you wait
>> for the other process to finish.
>>
>> Here is a link to a man page
>> http://www.mkssoftware.com/docs/man3/execl.3.asp
>>
>> but you will find more complete information for these functions in
>> your own help from the Visual Studio IDE.
>>
>>
>> If you want to convert your .exe into a DLL you may be interested
>> in looking at the code in
>>
>>
>>         InsightApplications/VolviewPlugins
>>
>>
>> Please let me know if you have more questions,
>>
>>
>>    Thanks
>>
>>
>>
>>       Luis
>>
>>
>> ---------------------
>> Gopal Karemore wrote:
>>
>>> Dear luis
>>>  I have built ITK using MS visual studio 6.0. But my GUI is on .NET 
>>> framework. I want to Pass parameter from GUI to one of ITK function 
>>> (ImageEntropy1.cxx) to calculate entropy and give it back to c#.Net 
>>> code.
>>>  As you can see, I have made EXE of ImageEntropy1 which will take 
>>> image as a parameter. I dont have single dll which will do this. I 
>>> can use Pinvoke function from C#.NET to access remote DLL.But I have 
>>> EXE.How to do this?
>>>  Thanking you for your consisting support for my project.
>>>  Regards
>>> K.Gopal
>>>  ///////////////////////////////////////////////
>>> Philips Medical System - Ultrasound
>>> Philips Innovation Campus
>>> Manyata Tech Park, Nagavara
>>> Bangalore - 560045
>>>  Tel : +91-80-4189 0000 Extn: 1329
>>> Mob: +91-9900216886
>>> Website: www.goops.9k.com <http://www.goops.9k.com>
>>> /////////////////////////////////////////////// 
> 
> 
> 


More information about the Insight-users mailing list