史蒂夫(Steve)与MATLAB进行图像处理

图像处理概念,算法和MATLAB

Registering Hand-Held Pictures

The typical modern French* horn, pictured below, has about 23 total feet of tubing. At the beginning and the end, the tubing is conical. In the middle, the tubing is cylindrical.
img_4910.jpeg
Depending on which valve levers are pressed, a player might be buzzing into single tube that is anywhere from 9 feet to 17 feet long (approximately). For a personal project, I wanted to create a visual illustration of these various lengths. I used an extension pole and got some help in taking several pictures. My helper used a handheld phone.
A = imread('a.jpg');
b = imread('B.jpg');
C = imread('C.jpg');
Tiledlayout(2,2)
Nexttile
imshow(A,“插值”,,,,“双线”
title(“图像A(f号长,12英尺)”
Nexttile
imshow(B,“插值”,,,,“双线”
title(“图像b(b-flat喇叭的长度,9英尺)”
Nexttile
imshow(C,“插值”,,,,“双线”
title('Image C (length of B horn, 17 feet)'
我想使用这些图片制作一个复合材料,使您可以在视觉上比较三极长。问题在于,这三张图片不彼此对齐,这使得创造了精确的复合挑战。
Let me use imshowpair to illustrate what I mean, using images A and B.
Clf
imshowpair(A,B)
看来这两个图像通过翻译和较小的旋转而彼此不同。
为了实现我的目标,我需要首先让这三张图片彼此对齐。然后,我可以裁剪它们并创建我的复合材料。
Sounds like an image registration and spatial referencing problem!
Here's the plan:
  1. Infer a geometric transform that aligns image B to image A.
  2. Infer a geometric transform that aligns image C to image A.
  3. 使用上面发现的转换,将图像B和C翘曲到与图像A相同的空间参考。
  4. Crop all three images closely around me holding the pole in the center.
  5. Create a composite of the three images.
我将在图像处理工具箱和计算机视觉工具箱中使用工具。

Register image B to image A

将图像转换为灰度以进行注册程序。
ag = rgb2gray(a);
bg = rgb2gray(b);
在这两个图像中使用冲浪功能检测(来自计算机视觉工具箱)。
%检测冲浪功能
A_points = detectSURFFeatures(Ag);
b_points =检测表(bg);
从检测到的特征点提取功能信息。
[a_features,a_valid_points] = extractfeatures(ag,a_points);
[B_features,B_valid_points] = extractFeatures(Bg,B_points);
匹配两个图像的功能点。
index_pairs_b_a = matchfeatures(a_features,b_features);
a_matched_points = a_valid_points(index_pairs_b_a(:,1));
B_matched_points = B_valid_points(index_pairs_B_A(:,2));
Infer a projective geometric transformation that will align image B with image A.
tform_B_A = estimateGeometricTransform(B_matched_points,A_matched_points,'projective');
tform_b_a.t
ans = 3×3single matrix
1。02110。03460。0000 -0.0196 1.0139 0.0000 31.3027 47.2352 1.0000
Align image B to image A. Note especially the use of the 输出视图 选项 IMWARP ;这用于计算与图像A所占据的相同空间矩形的图像翘曲结果。
a_ref = imref2d(size(ag));
B_reg = imwarp(B, tform_B_A,'OutputView',a_ref);
视觉检查结果。
figure
imshowpair(A,B_reg,“插值”,,,,“双线”

注册图像c使用相同的步骤图像A图像A

Cg = rgb2gray(C);
C_points = detectSURFFeatures(Cg);
[C_FEATURES,C_VALID_POINTS] = ExtractFeatures(cg,c_points);
index_pairs_c_a = matchfeatures(a_features,c_features);
a_matched_points = a_valid_points(index_pairs_c_a(:,1));
c_matched_points = c_valid_points(index_pairs_c_a(:,2));
tform_C_A = estimateGeometricTransform (C_matched_points,A_matched_points,'projective');
c_reg = imwarp(c,tform_c_a,'OutputView',a_ref);
imshowpair(A,C_reg,“插值”,,,,“双线”

Crop images to a common rectangle

既然图像A,B和C都已注册为图像A的空间参考,则可以使用相同位置的相同矩形裁剪所有三个。
r = [1100 450 600 1600];
A_c = imcrop(A,r);
b_reg_c = imcrop(b_reg,r);
c_reg_c = imcrop(c_reg,r);

Make a tiled composite

最后,我会用 imtile 为了制作可以保存到JPEG文件的图块复合图像。
ABC = imtile({B_reg_c,A_c,C_reg_c},。。。
'BorderSize',50,。。。
'BackgroundColor',,,,'白色的');
imshow(ABC,“插值”,,,,“双线”
令我惊讶的是,我可以在腿上握住的乐器确实可以是一根管子,只要右图所示的杆子。
*现代乐器不是法国的,所以 法国号角 is a misnomer, strictly speaking. Many players refer to the instrument simply as a 喇叭,,,, and this is the recommendation of the International Horn Society. In the United States,however, most people who are not orchestral musicians will be confused by the term 喇叭 ,,,,and so I use 法国号角 here.
|
  • 打印
  • 发送电子邮件

Comments

To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.