2016-10-16 11 views
0

こんにちは皆、私はこの問題で助けが必要です。私は値を返すmatlab関数を持っています 'pourcentage'私はPHPファイルでこの値を取得したい。ここ は私の関数はmatlab関数の出力はPHPで

function A=computeSIFT(input_img_path) 
    fabric = imread(input_mg_path); 
    I = rgb2gray(fabric); 
    %I=histeq(I,255); 
    %I=floor(I/8); 
    maxi = max(I(:)) 
    seuil = maxi-50 
    for k=1:size(I,1) 
for j=1:size(I,2) 
    if(I(k,j)<seuil) 
     I(k,j)=0; 
    else 
     I(k,j)=255; 
    end 
end 
end 
[~, threshold] = edge(I, 'sobel'); 
fudgeFactor = .5; 
BWs = edge(I,'sobel', threshold * fudgeFactor); 
figure, imshow(BWs), title('binary gradient mask'); 
se90 = strel('line', 3, 90); 
se0 = strel('line', 3, 0); 
BWsdil = imdilate(BWs, [se90 se0]); 
figure, imshow(BWsdil), title('dilated gradient mask'); 
BWdfill = imfill(BWsdil, 'holes'); 
figure, imshow(BWdfill); 
title('binary image with filled holes'); 
BWnobord = imclearborder(BWdfill, 4); 
figure, imshow(BWnobord), title('cleared border image'); 
seD = strel('diamond',1); 
BWfinal = imerode(BWnobord,seD); 
BWfinal = imerode(BWfinal,seD); 
figure, imshow(BWfinal), title('segmented image'); 
BWoutline = bwperim(BWfinal); 
Segout = I; 
Segout(BWoutline) = 255; 
figure, imshow(Segout), title('outlined original image'); 
white=0; 
black=0; 
for z=1:size(I,1) 
for m=1:size(I,2) 
    if I(z,m)==0 
     black=black+1; 
    else 
     white= white+1; 
    end 
end 
end 
black 
white 
pourcentage = (white/(size(I,1)*size(I,2)))*100 
A=pourcentage; 
end 

であり、これは私のPHPコードです:

$command = "matlab -nojvm -r \"A=computeSIFT('$target_path');exit\""; 
system($command,$output); 


$response['message'] = 'yeeeeeeeeeeeeees'.$output; 

私は$出力にpourcentageを取得することができますか?

答えて

0
  1. あなたmatlab機能は、出力は(dispまたはfprintfを使用して)コンソールになります必要があります。
    (あなたが任意の出力を取得するかどうかを確認するためにあなたのシェル(CMD/Linuxシェル)に$commandで機能ラインを実行してみてください。)

  2. は、PHPのsystem機能は、出力の唯一最後行を返します(それは戻り値ですが、2番目のパラメータではありません)。
    通話のenitre出力が必要な場合にのみ、最後の行で[OK]を、あなたは


$output = system($command); 

を使用することができた場合はすることができますshell_exec機能:

$output = shell_exec($command);