How do I specify parameter types (specifically Image types) of a function in a .NET assembly created by MATLAB?
Show older comments
Hi everyone!
I have the following code in a MATLAB function;
function [ returnValue] = ProcessImage( passedImage )
originalImage = imread(passedImage);
[rowSize colSize] = size(originalImage);
returnValue = colSize
end
I built a .NET assembly with this bit of code. I then added it as a reference to a C#.NET application. I now need to pass an image from the .NET application this bit of code, which will process the image and return its column size.
I'm not sure how to go about the type setting. Cuz when I try it out, a syntax error is shown in Visual Studio saying that the argument expected is of type int.
Have I written the MATLAB function declaration correctly?
4 Comments
Geoff Hayes
on 28 Jun 2014
What is passedImage? Is it an image (incorrect) or a (string) filename (with path) to an image?
imread will read an image from a graphics file (see http://www.mathworks.com/help/matlab/ref/imread.html) and so the input must be a filename or URL.
Once the image is read, to get the number of columns just do
colSize = size(originalImage,2);
In the above, we get the second dimension (number of columns) from the image.
Lahiru
on 28 Jun 2014
Geoff Hayes
on 28 Jun 2014
So is the C# application that doesn't' like the return value from ProcessImage? If that is the case, then cast colSize as an integer
returnValue = int32(colSize);
The above is for a 32-bit signed integer. If something different is needed, then cast as appropriate.
Lahiru
on 28 Jun 2014
Answers (0)
Categories
Find more on Get Started with Microsoft .NET in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!