|
If I have an object of bitmap image in C#. How can I read it into Matlab?
The purpose: I want to build a C# Dll to include many Matlab functions so C# program can use it. Then I need to pass the image data to this Dll. One of the data is image, say in Bitmap format. I want this Dll to be able to directly read Bitmap object.
Usually in DLL, I can have a Matlab m file to read in an image from a file
filename = 'c:\1.bmp';
img = imread( filename);
...
Then, in C#, I need first save the bitmap into a file, and let the Dll to read it. Then save it as another file and let C# code to read in. That is not efficient.
What I want to do is like this: (Suppose I have a Matlab Dll called MatlabDll and a method "ProcessIt" in it.) And I referenced it in the C# project.
....
string filename = @"c:\1.bmp";
Bitmap img = new Bitmap(filename);
//First, do a lot of data processing in C#
//.....
//Then pass the Bitmap image object to MatlabDll for Matlab processing and return a //Bitmap object back to C#
Bitmap newimg = MatlabDll.ProcessIt(img);
How can I do this?
|