【问题标题】:how can i use lsqcurvefit for image registration?如何使用 lsqcurvefit 进行图像配准?
【发布时间】:2015-02-24 03:53:34
【问题描述】:

我有两个 3D 图像,我需要使用“lsqcurvefit”注册这两个图像。我知道我可以使用“imregister”,但我想在 Matlab 中使用“lsqcurvefit”来使用我自己的注册。我的图像遵循高斯分布。没有很好地记录我应该如何提供它,任何人都可以详细帮助我吗?

图像配准是使用仿射将源图像映射到目标图像的重复过程。我想使用强度基配准,并且我使用图像的所有体素。因此,我需要尽可能地适合这两个图像。

谢谢

【问题讨论】:

  • 在你的图像中是一个单一的高斯峰?还是多个高斯峰?
  • @Staus 多峰
  • 快速版本 - 使用类似 `imregionalmax' 的东西来查找局部最大值,围绕每个定义的大小(如预期的 sigma*3 左右)拍摄子图像,然后将每个图像拟合到 2d 高斯使用 lsqcurvefit。给定每个图像中的本地化结果列表,您可以使用 lsqcurvefit 拟合方程 LocalizationsB = 中的变换矩阵([cos theta, -sin theta, translate x; sin theta, cos theta, translate y; 0 0 1]) TransformMatrix * 本地化 A.
  • @Staus 感谢您的回复,如果我有单高斯峰怎么办?我发现我的一些图像是单高斯峰,提前感谢
  • 你至少需要两个点来定义一个带有旋转和平移的变换。给定一个您只能进行翻译,因此将上面的矩阵更改为 [1 0 TransX; 0 1 传输; 0 0 1] 在您有一个点的情况下,或者进行更多基于图像的配准。

标签: matlab image-processing image-registration


【解决方案1】:

这是一个如何使用lsqcurvefit 进行逐点图像配准的示例。基本上,您创建了一个函数,该函数采用一组点和一个仿射矩阵(我们将使用平移和旋转部分,但如果需要,您可以使用倾斜和放大)并返回一组新点。可能已经有一个内置函数,但它只有两行,所以很容易编写。该函数是:

function TformPts = TransformPoints(StartCoordinates, TransformMatrix)

TformPts = StartCoordinates*TransformMatrix;

这是一个脚本,它生成一些点,以随机角度和矢量旋转和平移它们,然后使用TransformPoints 函数作为lsqcurvefit 的输入来拟合注册所需的变换矩阵。然后它只是一个矩阵乘法来生成注册的点集。如果我们做的很好,当下面的代码运行时,红色圆圈(原始数据)将与黑色星星(移位然后注册的点)很好地对齐。

% 20 random points in x and y between 0 and 100
% row of ones pads out third dimension
pointsList = [100*rand(2, 20); ones(1, 20)];

rotateTheta = pi*rand(1); % add rotation, in radians
translateVector = 10*rand(1,2); % add translation, up to 10 units here

% 2D transformation matrix
% last row pads out third dimension
inputTransMatrix = [cos(rotateTheta), -sin(rotateTheta), translateVector(1);
                    sin(rotateTheta), cos(rotateTheta), translateVector(2);
                    0 0 1];


% Transform starting points by this matrix to make an array of shifted
% points.  
% For point-wise registration, pointsList represents points from one image,
% shiftedPoints points from the other image
shiftedPoints = inputTransMatrix*pointsList;
% Add some random noise
% Remove this line if you want the registration to be exact
shiftedPoints = shiftedPoints + rand(size(shiftedPoints, 1), size(shiftedPoints, 2));

% Plot starting sets of points
figure(1)
plot(pointsList(1,:), pointsList(2,:), 'ro');
hold on
plot(shiftedPoints(1,:), shiftedPoints(2,:), 'bx');
hold off

% Fitting routine
% Make some initial, random guesses
initialFitTheta = pi*rand(1);
initialFitTranslate = [2, 2];

guessTransMatrix = [cos(initialFitTheta), -sin(initialFitTheta), initialFitTranslate(1);
                    sin(initialFitTheta), cos(initialFitTheta), initialFitTranslate(2);
                    0 0 1];

% fit = lsqcurvefit(@fcn, initialGuess, shiftedPoints, referencePoints)             
fitTransMatrix = lsqcurvefit(@TransformPoints, guessTransMatrix, pointsList, shiftedPoints);

% Un-shift second set of points by fit values
fitShiftPoints = fitTransMatrix\shiftedPoints;

% Plot it up
figure(1)
hold on
plot(fitShiftPoints(1,:), fitShiftPoints(2,:), 'k*');
hold off

% Display start transformation and result fit
disp(inputTransMatrix)
disp(fitTransMatrix)

【讨论】:

    猜你喜欢
    • 2018-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-16
    • 2019-04-21
    • 2017-12-08
    • 2014-03-29
    相关资源
    最近更新 更多