我有两张图片,需要通过翻译和旋转将一张图片转换为另一张图片。为此我有一个这样的功能:如何调整fminunc的初始步骤?
function [differences] = cost_function(transformation)
disp(transformation);
offset_x = transformation(1); % one of the images will be shifted by these many
offset_y = transformation(2); % pixels in either direction
angle = transformation(3); % and rotated by this much
% snip:
% * transform the second image
% * otsu treshold both
% * xor the results
% * count pixels that xored
然后我试着找到它的最小值!
best_transform = fminunc(@cost_function, [0 0 0]);
然而,解算器日志显示一个很大的问题:
1.0e-007 *
0.1490 0 0
1.0e-007 *
0 0.1490 0
1.0e-007 *
0 0 0.1490
0 0 1
0.0000 0 1.0000
0 0.0000 1.0000
0 0 1.0000
0 0 0.3333
0.0000 0 0.3333
求解程序试图在每个维度有一点点微调,找到最佳线路进行的,但很明显偏移图像通过0.1490像素确实没有太大的作用,而将其自然移动0.1490弧度。然而,我不知道,其中0.1490实际上来自哪里。
The documentation在这里似乎没有建议。我如何增加求解器的初始步骤?