Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在matlab中知道旋转图像的旋转度?_Matlab_Image Processing_Octave - Fatal编程技术网

如何在matlab中知道旋转图像的旋转度?

如何在matlab中知道旋转图像的旋转度?,matlab,image-processing,octave,Matlab,Image Processing,Octave,我想: 步骤1)使用此代码将图像旋转20度rotateImage=imrotate(原始图像,20) 步骤2)如果可能,仅基于旋转图像或基于旋转图像和原始图像计算步骤1中使用的旋转度 matlab中有任何函数可以执行第2步或一个命题吗?此示例显示了执行第2步的一种方法: A = 'peppers.jpg'; img = im2double(imread(A)); img_r=imrotate(img,20,'nearest','crop'); % <-- this is the d

我想:

  • 步骤1)使用此代码将图像旋转20度
    rotateImage=imrotate(原始图像,20)

  • 步骤2)如果可能,仅基于旋转图像或基于旋转图像和原始图像计算步骤1中使用的旋转度


matlab中有任何函数可以执行第2步或一个命题吗?

此示例显示了执行第2步的一种方法:

A = 'peppers.jpg';
img = im2double(imread(A));
img_r=imrotate(img,20,'nearest','crop');   % <-- this is the distorted image
                                           %     rotated 20 deg

xopt = fminsearch(@(x) imr(x,img_r,img), 10);  % <-- start with 10 deg as guess
该函数包装
imrotate
,生成一个最小化的目标函数,以便
fminsearch
可以使用该函数

这显示原始、扭曲和反转图像(角度如上所述确定):

注意限制:旋转后的图像会被裁剪,以便在计算目标函数期间可以进行逐点比较。
这可能不是最好的解决方法,因为我认为有一些形态学算法可以用更一般的方式回答你的特定问题。但它仍然有效

您可能需要检查。我用傅里叶-梅林变换来恢复旋转。它的准确度高达1度。我想你需要投入一些时间+别忘了检查一些关于傅里叶-梅林变换的论文

这里是我过去发布的一些例子,其中一些是针对特定情况的(通过检测角、线、边等作为两幅图像中的特征,并使用它们来恢复变换):,Matlab为此提供了一些内置功能。请参阅“查找图像旋转”网页,并使用特征匹配算法-
function obj= imr(x,img1,img2);
img1_r = imrotate(img1,x,'nearest','crop');
obj = sum((img2(:)-img1_r(:)).^2);