各位大神,本人最近在做老师给的一个混编的项目。matlab的库已经生成好了,其他好几个程序的混编工作也结束了,但是这个程序就是搞不定。matlab里已经调试很好了,一切正常,但是生成的库在c++中运行就报错
错误如图,这是我的c代码:
CImage imgin;
CImage imgout;
imgin.Load(_T("test.bmp"));
int pit = imgin.GetPitch();
int h = imgin.GetHeight();
int w = imgin.GetWidth();
unsigned char* pImgin = (unsigned char*)imgin.GetPixelAddress(0,h-1);
imgout.Create(w,h,8);
unsigned char* pImgout = (unsigned char*)imgout.GetPixelAddress(0,h-1);
// 创建输入mx字符串数组
mwArray DataIn(w,h,mxUINT8_CLASS);
mwArray DataOut(w,h,mxUINT8_CLASS);
mwArray W(1,1,mxDOUBLE_CLASS);
mwArray H(1,1,mxDOUBLE_CLASS);
DataIn.SetData((mxUint8*)pImgin,w*h);
W.SetData(&w,1);
H.SetData(&h,1);
// 调用演示函数
test_fourier(1,DataOut,DataIn);
DataOut.GetData((mxUint8*)pImgout,w*h);//这行报错,不过应该是上一行调用失败的原因。
PaletteChangedToGray(&imgout);
imgout.Save(_T("out.bmp"));
matlab出错的地方
border_restored = zeros(size(image_edged));
xx=real(border_ifft);yy=imag(border_ifft);
yyt=floor(yy);xxt=floor(xx);
if(length(xxt)==0)
return ;
end
hind=sub2ind(size(border_restored),yyt,xxt);//应该是这一行的原因。
border_restored(round(hind))=1;
请教各位大神有没有人知道这个原因。谢谢了