日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab 三维图像配准,[转载]Matlab实现多种图像配准(转)

發布時間:2023/12/3 循环神经网络 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab 三维图像配准,[转载]Matlab实现多种图像配准(转) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文講述如何利用Matlab Image Processing Toolbox中的圖像配準工具實現線性正投影、仿射、投影、多項式、分段線性、局部加權平均配準的過程。

實驗平臺

X86 PC,Windows XP sp2, Matlab 7.1

資源的獲取

matlab工具的使用方法:查看幫助mage Processing Toolbox User's Guide——Image registration。

涉及配準方法簡介

該工具箱提供的配準方法均需手工選擇圖像間的匹配點對(control points pair),均屬于交互配準方法。其基本過程為:讀入圖像數據->在兩副圖像上選擇足夠匹配點->選擇配準算法,計算變換參數->變換圖像。

假設input image(輸入圖像)為欲進行配準的圖像,base image為配準是的參考圖像。以下是我參考matlab幫助給出了簡介。

1.線性正投影(linear conformal):最簡單。平面映射成平面。

當輸入輸入圖像與參考圖像對比,只是存在全局的平移、旋轉、縮放或其三者組合的差別時(正方形仍對應正方形),選擇此配準方法。此方法至少需要2對匹配點。

2.仿射(affine):將平行線轉換成平行線。

當輸入圖像形狀存在切變現象(正方形對應平行四邊形),選此法。至少需3對匹配點。

3.投影(projective):將直線映射成直線。

如果輸入圖像呈現傾斜,翹起現象,選此法。至少需4對匹配點。

4.多項式(polynomial):將直線映射成曲線。

如果輸入圖像出現不規則曲變,采用此法。Matlab中提供有2、3、4次冪的實現,分別至少需要6,10,10對匹配點。

5.分段線性(piecewise linear)

如果輸入圖像的各個局部之間的退化模式明顯不一樣,選此法。至少需要4對匹配點。

6.局部加權平均(local weighted mean)

與分段線性一致,但效果較之好。至少需要6對(推薦12對)匹配點。

實驗步驟

1.讀取圖像數據。

因為源圖像以矩陣形式存在一個二進制的文件里,用fread可將其讀取到變量矩陣中。將讀取文件編制成一個子函數(RTIread.m),源代碼如下:

function imMatrix=RTIread(FILENAME,SIZE)

%RTIreadRead the image matrix from binary "Registration Test Image" file.

%imMatrix=RTIread(FILENAME,SIZE) opens the file FILENAME, and reads the

%number of elements specified by SIZE.

%

%FILENAME is a string containing the name of the file to be opened.

%Valid entries for SIZE are:

%Nread N elements into a column vector.

%infread to the end of the file.

%[M,N]read elements to fill an M-by-N matrix, in column order.

%N can be inf, but M can't.

%

%It returns the image matrix.

fid=fopen(FILENAME,'r');

imMatrix=fread(fid,SIZE,'uint8=>uint8');

fclose(fid);

%image(imMatrix);

這里我們選取了兩張600×600的圖片,文件名為“casitas84”和“casitas86”。運行以下代碼讀取圖像矩陣:

% 1. Read the images into the MATLAB

workspace.

base=RTIread('casitas84',[600,600]);

input=RTIread('casitas86',[600,600]);

2.選取匹配點(control points)。

根據預定的配準方法,選定足夠的匹配點對。運行下列代碼:

% 2.Specify control point pairs n the images and

save.

cpselect(input,base);%please

select 15 points for test.

出現GUI界面。

操作很簡單,只需注意選點要均勻布開,以增加其代表性。選定完畢,File-> Save Points to

Workspace將數據保存到工作區中。Workspace立刻多出兩個N×2的數組(其中N為選定的匹配點對數),分別為input_points和base_points,如:

input_points =

119.5185193.5926

168.9012242.9753

105.9383140.5062

459.0247131.8642

313.3457257.7901

292.3580165.1975

276.308633.0988

283.7160380.0123

76.3086297.2963

135.567983.7160

360.2593313.3457

94.8272446.6790

70.1358354.0864

181.2469361.4938

381.2469460.2593

252.8519433.0988

3.利用十字相關法調整選定了的匹配點。

這步可選。運行代碼:

% 3.Fine-tune the control points using

cross-correlation.

input_points_corr =

cpcorr(input_points,base_points,input,base); %optimism the

points

input_points_corr為優化后在輸入圖片的對應匹配點。

4.計算變換公式的參數。

利用cp2tform,選定變換類型(即配準方法),計算變換參數。以下只需選定一種即可。

% 4.Specify the type of transformation to be used

and infer its parameters

% (1) not Fine-tune points

Tlinear =

cp2tform(input_points,base_points,'linear conformal');

Taffine =

cp2tform(input_points,base_points,'affine');

Tprojective =

cp2tform(input_points,base_points,'projective');

Tpolynomial2 =

cp2tform(input_points,base_points,'polynomial',2);

Tpolynomial3 =

cp2tform(input_points,base_points,'polynomial',3);

Tpolynomial4 =

cp2tform(input_points,base_points,'polynomial',4);

Tpiecewise =

cp2tform(input_points,base_points,'piecewise linear');

Tlwm =

cp2tform(input_points,base_points,'lwm');

% (2)Fine-tune points

fTlinear =

cp2tform(input_points_corr,base_points,'linear

conformal');

fTaffine =

cp2tform(input_points_corr,base_points,'affine');

fTprojective =

cp2tform(input_points_corr,base_points,'projective');

fTpolynomial2 =

cp2tform(input_points_corr,base_points,'polynomial',2);

fTpolynomial3 =

cp2tform(input_points_corr,base_points,'polynomial',3);

fTpolynomial4 =

cp2tform(input_points_corr,base_points,'polynomial',4);

fTpiecewise =

cp2tform(input_points_corr,base_points,'piecewise

linear');

fTlwm =

cp2tform(input_points_corr,base_points,'lwm');

諸如Tlinear的變量為一個稱為TFORM的數據結構,尚沒做仔細研究:

Tlinear =

ndims_in:

2

ndims_out:

2

forward_fcn:

@fwd_affine

inverse_fcn:

@inv_affine

tdata:

[1x1 struct]

5.變換圖像。

% 5.Transform the unregistered image to bring it

into alignment.

title('image registration polynomial

method');

subplot(2,2,1);

imshow(base);

title('Base image');

subplot(2,2,2);

imshow(input);

title('Input image');

subplot(2,2,3);

imshow(imtransform(input,Tpolynomial2));

title('registered image');

subplot(2,2,4);

imshow(imtransform(input,fTpolynomial2));

title('registered image(fine-tune

points)');

結果如下:

總結

1.image和imshow區別。前者視base,input此類二維圖片矩陣為索引圖像,在系統的index庫中選取顏色。

2.選擇適當的方法來建立轉換參數,并非算法越復雜越好,應參考成像因素(退化因素)。

3.尚沒有看出十字相關法的好處。

4.

利用cpselect選擇匹配點,cpselect可以返回一個GUI句柄。欲實現如下功能:當打開cpselect GUI

時,m文件程序暫停運行,關閉之后繼續執行。因為對GUI編程不懂,?使用了waitfor,pause函數都沒法實現。嘗試中……

總結

以上是生活随笔為你收集整理的matlab 三维图像配准,[转载]Matlab实现多种图像配准(转)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。