Matlabにアルゴリズムを書きました。したがって、私はそれを.Net上で使いたいと思っています。 Matlabライブラリコンパイラで.Netを使って.mファイルを.dllに完全に変換しました。まず、Matlab関数をパラメータなしで.dllに変換しようとしましたが、.NET上でうまくいきました。しかし、私はパラメータでその関数を使用したい、私はいくつかのエラーが下になっている。パラメータは基本的に画像です。私はX 2988. 5312でxxx.jpgと呼ばれる同じ画像を使用しかし、私は以下のこのエラーを取得しています。このビットマップをMWArray(Matlab Array)に変換する方法
static void Main(string[] args)
{
DetectDots detectDots = null;
Bitmap bitmap = new Bitmap("xxx.jpg");
//Get image dimensions
int width = bitmap.Width;
int height = bitmap.Height;
//Declare the double array of grayscale values to be read from "bitmap"
double[,] bnew = new double[width, height];
//Loop to read the data from the Bitmap image into the double array
int i, j;
for (i = 0; i < width; i++)
{
for (j = 0; j < height; j++)
{
Color pixelColor = bitmap.GetPixel(i, j);
double b = pixelColor.GetBrightness(); //the Brightness component
bnew.SetValue(b, i, j);
}
}
MWNumericArray arr = bnew;
try
{
detectDots = new DetectDots();
detectDots.Detect(arr);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
のようなこのI = imread('xxx.jpg'); Detect(I);
だから私のC#のコードのようにMatlabの関数を呼び出します。
... MWMCR::EvaluateFunction error ...
Index exceeds matrix dimensions.
Error in => DetectDots.m at line 12.
... Matlab M-code Stack Trace ...
at
file C:\Users\TAHAME~1\AppData\Local\Temp\tahameral\mcrCache9.0\MTM_220\MTM\DetectDots.m, name DetectDots, line 12.
重要なことは、「インデックスが行列の次元を超えています」ということです。ビットマップをMWArrayに変換するのは本当ですか?何が問題ですか?