如何计算图像的流矩阵?

时间:2017-05-03 17:59:25

标签: matlab image-processing

我想为图像计算EarthmoversDistance。我不知道如何为图像或区域计算FlowMatrix。

请帮帮我

提前致谢。

1 个答案:

答案 0 :(得分:0)

尝试使用matlab https://de.mathworks.com/help/optim/ug/fmincon.html中的fmincon函数 这使您可以将目标作为匿名函数(@运算符)。我从source of example code

复制了一个示例代码
 A = magic (3)
con = @constraints % we define a function file "constraints.m" that contains the constraints
min = @(B) -(sum(sum(A.*B))) % since all optimisation in Matlab can find minimum so we are trying to minimise the negetive of the objective.
a = [];
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];
x0 = zeros(3); % starting point for optimization
[sol, fval] = fmincon(min,x0,a,b,Aeq,beq,lb,ub,con) % This would give you 'B' and value of 'sum' (negetively minimised)
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
 % the contents of the file "constraints.m" (kept in same folder) are as following:-
 function [c,ceq] = constraints(x)
 c = x*[1;2;3] - [51;62;37];
 ceq = [];
 end
 % [1;2;3] corresponds to 'c' in the question
 % [51;62;37] corresponds to 'd' in the question
 % imply Bc <= d  (in question its Bc < d (without equalto))

顺便说一下,下次使用更具体的文字,提供示例代码,并尝试找到与您的问题类似的含义。特别是最后一点可能导致了很多混乱,因为添加标签计算机视觉以及关于图像流矩阵的问题误导读者认为你在谈论光流(计算机视觉中的一个重要主题)。 p>

请不要忘记设置绿色复选标记。祝你的统计数据好运!