1 / 6

如何從 BCB 傳送字串給 Matlab

如何從 BCB 傳送字串給 Matlab. 為何要從 BCB 傳字串給 Matlab. 因為想利用 MATLAB 的便利性來實作視覺密碼,會節省很多時間,但 MATLAB 對程式的介面製作 不是很好上手,所以就利用 BCB 的介面。 利用 BCB 的介面來讀取圖片,再把圖片路徑的字串傳給 MATLAB , MATLAB 就可以讀取到該圖片,就可以對圖片做處理。. BCB 傳送字串給 Matlab. 必要的宣告 #include "engine.h“ Engine *eng; mxArray *Impath;. BCB 傳送字串給 Matlab(cont.).

aspen
Download Presentation

如何從 BCB 傳送字串給 Matlab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 如何從BCB傳送字串給Matlab

  2. 為何要從BCB傳字串給Matlab • 因為想利用MATLAB的便利性來實作視覺密碼,會節省很多時間,但MATLAB對程式的介面製作 不是很好上手,所以就利用BCB的介面。 • 利用BCB的介面來讀取圖片,再把圖片路徑的字串傳給MATLAB, MATLAB就可以讀取到該圖片,就可以對圖片做處理。

  3. BCB傳送字串給Matlab • 必要的宣告 • #include "engine.h“ • Engine *eng; • mxArray *Impath;

  4. BCB傳送字串給Matlab(cont.) • BCB中開圖的程式碼: if(OpenPictureDialog1->Execute()) { AnsiString path; path=OpenPictureDialog1->FileName; Image1->Picture->Bitmap->LoadFromFile(path); Impath=mxCreateString(path.c_str()); engPutVariable(eng,"Impath",Impath); engEvalString(eng,"Im=imread(Impath);"); }

  5. 如何將處理過的圖片傳回BCB • 這裡所用的方 法是由MATLAB存好圖檔,再由BCB去讀取。要注意的是MATLAB存圖檔的指令是”imwrite(A, filename, fmt)”,A 是要存的圖, filename是的檔名,fmt是格式。 • 例如:imwrite(im, ‘picture.bmp’ , ‘bmp’)

  6. 如何將處理過的圖片傳回BCB(cont.) • MATLAB存圖檔的位置是在Current Directory,其預設值是在C:\MATLAB701\work,如果要改變位置可在BCB中加入engEvalString(eng,“cd C:/‘Documents and Settings/’kAMD/桌面/Matlab_function/;”); • MATLAB完成存圖的動作後,BCB即可讀入圖檔。 • 目前的方法要先設定好存圖的位置,在BCB的程式中加入該路徑。

More Related