Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey guys i wanna get unit8 variable from matlab with c# . For this purpose, i write below code but doesn't work. how can i do this?
C#
var activationContext = Type.GetTypeFromProgID("matlab.application.single");
var matlab = (MLApp.MLApp)Activator.CreateInstance(activationContext);
byte b = new byte();
string a = "RGB = imread('c:\02.jpg');" +


" I=double(RGB);" +
" W=size(I,2);" +
" H=size(I,1);" +

" cform = makecform('srgb2lab');" +
" lab = applycform(RGB,cform);" +
" b=lab(:,:,2);" +

" [SkinIndexRow,SkinIndexCol] =find(127<b);" +

" SN=zeros(H,W);" +
" for ind=1:length(SkinIndexRow)" +
"    i= SkinIndexRow(ind);" +
"  j= SkinIndexCol(ind);" +
"  SN(i,j)=1;" +
"end " +

"L = bwlabel(SN,8); " +
"BB  = regionprops(L, 'BoundingBox'); " +
"bboxes= cat(1, BB.BoundingBox); " +
"lenRegions=size(bboxes,1); " +

"rgb=label2rgb(L); ";
object f = matlab.GetVariable(a, "rgb");
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900