我有兩張圖片,需要通過翻譯和旋轉將一張圖片轉換爲另一張圖片。爲此我有一個這樣的功能:如何調整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在這裏似乎沒有建議。我如何增加求解器的初始步驟?