matlab - Propose Fixed-Point Data Types Using an Instrumented Mex Function -
this matlab function:
function [mask] = computemask (i, threshold, win_var, borderx, bordery) coder.extrinsic('imfilter'); %-- compute variances of rgb , ir patches mean_i = imfilter(i,ones(win_var)/win_var/win_var,'same','symmetric','conv'); mean2_i = imfilter(i.^2,ones(win_var)/win_var/win_var,'same','symmetric','conv'); std_i= real(sqrt(mean2_i-mean_i.^2)+1e-5); mask= std_i>threshold; % add border of image mask % (filters not complete @ border) mask(1:((bordery-1)/2),:)=0; mask((end-(bordery-1)/2):end,:)=0; mask(:,1:((borderx-1)/2))=0; mask(:,(end-(borderx-1)/2):end)=0; % add area vignetting strong cy=floor(size(mask,1)/2); cx=floor(size(mask,2)/2); [x,y]=meshgrid(1:size(mask,2),1:size(mask,1)); mask(((x-cx).^2+(y-cy).^2)>8e4)=0; %mask(((x-cx).^2+(y-cy).^2)>1.3e4)=0; return
when trying build build "instrumented mex function" these errors: ??* ? expected either logical, char, int, fi, single, or double. found mxarray. mxarrays returned calls matlab interpreter , not supported inside expressions. may used on right-hand side of assignments , arguments extrinsic functions.*
error in ==> computemask line: 21 column: 18: std_i= real(sqrt(mean2_i-mean_i.^2)+1e-5);
how fix these problems? please me !!! thank much
since declared imfilter extrinsic, generated code call matlab run function. result in mxarray type. coder convert mxarray type native type should initialize outputs of imfilter before calling imfilter. example, if output of imfilter of same type , size input i, use
mean_i = i; mean_i = imfilter(i,ones(win_var)/win_var/win_var,'same','symmetric','conv');
note imfilter still not generate code. imfilter still called in matlab.
you can see documentation @ http://www.mathworks.com/help/fixedpoint/ug/calling-matlab-functions.html in section "converting mxarrays known types".
Comments
Post a Comment