function [Yl,Yh,Yscale] = dtwavexfm2(X,nlevels,biort,qshift);
% Function to perform a n-level DTCWT-2D decompostion on a 2D matrix X
%
% [Yl,Yh,Yscale] = dtwavexfm2(X,nlevels,biort,qshift);
%
% X -> 2D real matrix/Image
%
% nlevels -> No. of levels of wavelet decomposition
%
% biort -> 'antonini' => Antonini 9,7 tap filters.
% 'legall' => LeGall 5,3 tap filters.
% 'near_sym_a' => Near-Symmetric 5,7 tap filters.
% 'near_sym_b' => Near-Symmetric 13,19 tap filters.
%
% qshift -> 'qshift_06' => Quarter Sample Shift Orthogonal (Q-Shift) 10,10 tap filters,
% (only 6,6 non-zero taps).
% 'qshift_a' => Q-shift 10,10 tap filters,
% (with 10,10 non-zero taps, unlike qshift_06).
% 'qshift_b' => Q-Shift 14,14 tap filters.
% 'qshift_c' => Q-Shift 16,16 tap filters.
% 'qshift_d' => Q-Shift 18,18 tap filters.
%
%
% Yl -> The real lowpass image from the final level
% Yh -> A cell array containing the 6 complex highpass subimages for each level.
% Yscale -> This is an OPTIONAL output argument, that is a cell array containing
% real lowpass coefficients for every scale.
%
%
% Example: [Yl,Yh] = dtwavexfm2(X,3,'near_sym_b','qshift_b');
% performs a 3-level transform on the real image X using the 13,19-tap filters
% for level 1 and the Q-shift 14-tap filters for levels >= 2.
%
% Nick Kingsbury and Cian Shaffrey
% Cambridge University, Sept 2001
if isstr(biort) & isstr(qshift) %Check if the inputs are strings
biort_exist = exist([biort '.mat']);
qshift_exist = exist([qshift '.mat']);
if biort_exist == 2 & qshift_exist == 2; %Check to see if the inputs exist as .mat files
load (biort);
load (qshift);
else
error('Please enter the correct names of the Biorthogonal or Q-Shift Filters, see help DTWAVEXFM2 for details.');
end
else
error('Please enter the names of the Biorthogonal or Q-Shift Filters as shown in help DTWAVEXFM2.');
end
orginal_size = size(X);
if ndims(X) >= 3;
error(sprintf('The entered image is %dx%dx%d, please enter each image slice separately.',orginal_size(1),orginal_size(2),orginal_size(3)));
end
% The next few lines of code check to see if the image is odd in size, if so an extra ...
% row/column will be added to the bottom/right of the image
initial_row_extend = 0; %initialise
initial_col_extend = 0;
if any(rem(orginal_size(1),2)), %if sx(1) is not divisable by 2 then we need to extend X by adding a row at the bottom
X = [X; X(end,:)]; %Any further extension will be done in due course.
initial_row_extend = 1;
end
if any(rem(orginal_size(2),2)), %if sx(2) is not divisable by 2 then we need to extend X by adding a col to the left
X = [X X(:,end)]; %Any further extension will be done in due course.
initial_col_extend = 1;
end
extended_size = size(X);
if nlevels == 0, return; end
%initialise
Yh=cell(nlevels,1);
if nargout == 3
Yscale=cell(nlevels,1); %this is only required if the user specifies a third output component.
end
S = [];
sx = size(X);
if nlevels >= 1,
% Do odd top-level filters on cols.
Lo = colfilter(X,h0o).';
Hi = colfilter(X,h1o).';
% Do odd top-level filters on rows.
LoLo = colfilter(Lo,h0o).'; % LoLo
Yh{1} = zeros([size(LoLo)/2 6]);
Yh{1}(:,:,[1 6]) = q2c(colfilter(Hi,h0o).'); % Horizontal pair
Yh{1}(:,:,[3 4]) = q2c(colfilter(Lo,h1o).'); % Vertical pair
Yh{1}(:,:,[2 5]) = q2c(colfilter(Hi,h1o).'); % Diagonal pair
S = [ size(LoLo) ;S];
if nargout == 3
Yscale{1} = LoLo;
end
end
if nlevels >= 2;
for level = 2:nlevels;
[row_size col_size] = size(LoLo);
if any(rem(row_size,4)), % Extend by 2 rows if no. of rows of LoLo are divisable by 4;
LoLo = [LoLo(1,:); LoLo; LoLo(end,:)];
end
if any(rem(col_size,4)), % Extend by 2 cols if no. of cols of LoLo are divisable by 4;
LoLo = [LoLo(:,1) LoLo LoLo(:,end)];
end
% Do even Qshift filters on rows.
Lo = coldfilt(LoLo,h0b,h0a).';
Hi = coldfilt(LoLo,h1b,h1a).';
% Do even Qshift filters on columns.
LoLo = coldfilt(Lo,h0b,h0a).'; %LoLo
Yh{level} = zeros([size(LoLo)/2 6]);
Yh{level}(:,:,[1 6]) = q2c(coldfilt(Hi,h0b,h0a).'); % Horizontal
Yh{level}(:,:,[3 4]) = q2c(coldfilt(Lo,h1b,h1a).'); % Vertical
Yh{level}(:,:,[2 5]) = q2c(coldfilt(Hi,h1b,h1a).'); % Diagonal
S = [ size(LoLo) ;S];
if nargout == 3
Yscale{level} = LoLo;
end
end
end
Yl = LoLo;
if initial_row_extend == 1 & initial_col_extend == 1;
warning(sprintf(' \r\r The image entered is now a %dx%d NOT a %dx%d \r The bottom row and rightmost column have been duplicated, prior to decomposition. \r\r ',...
extended_size(1),extended_size(2),orginal_size(1),orginal_size(2)));
end
if initial_row_extend == 1 ;
warning(sprintf(' \r\r The image entered is now a %dx%d NOT a %dx%d \r Row number %d has been duplicated, and added to the bottom of the image, prior to decomposition. \r\r',...
extended_size(1),extended_size(2),orginal_size(1),orginal_size(2),orginal_size(1)));
end
if initial_col_extend == 1;
warning(sprintf(' \r\r The image entered is now a %dx%d NOT a %dx%d \r Col number %d has been duplicated, and added to the right of the image, prior to decomposition. \r\r',...
extended_size(1),extended_size(2),orginal_size(1),orginal_size(2),orginal_size(2)));
end
return
%==========================================================================================
% ********** INTERNAL FUNCTION **********
%==========================================================================================
function z = q2c(y)
% function z = q2c(y)
% Convert from quads in y to complex numbers in z.
sy = size(y);
t1 = 1:2:sy(1); t2 = 1:2:sy(2);
j2 = sqrt([0.5 -0.5]);
% Arrange pixels from the corners of the quads into
% 2 subimages of alternate real and imag pixels.
% a----b
% | |
% | |
% c----d
% Combine (a,b) and (d,c) to form two complex subimages.
p = y(t1,t2)*j2(1) + y(t1,t2+1)*j2(2); % p = (a + jb) / sqrt(2)
q = y(t1+1,t2+1)*j2(1) - y(t1+1,t2)*j2(2); % q = (d - jc) / sqrt(2)
% Form the 2 subbands in z.
z = cat(3,p-q,p+q);
return
没有合适的资源?快使用搜索试试~ 我知道了~
基于纹理的图像相似性计算
共374个文件
jpg:357个
m:10个
asv:3个
4星 · 超过85%的资源 需积分: 35 14 下载量 111 浏览量
2008-07-09
17:06:05
上传
评论
收藏 4.15MB RAR 举报
温馨提示
这个程序是将一个现有的程序进行改进的,不是原创。这里发布只是供大家学习用
资源推荐
资源详情
资源评论
收起资源包目录
基于纹理的图像相似性计算 (374个子文件)
SearchTexture.asv 5KB
image_sim_cal.asv 4KB
disp_white.asv 4KB
Thumbs.db 2.52MB
Thumbs.db 323KB
Thumbs.db 143KB
image_sim_cal.fig 14KB
13.jpg 157KB
12.jpg 90KB
C_4.jpg 12KB
A_11.jpg 12KB
C_1.jpg 12KB
C_1.jpg 12KB
A_15.jpg 12KB
C_3.jpg 12KB
A_3.jpg 12KB
C_5.jpg 12KB
A_14.jpg 12KB
A_10.jpg 11KB
C_2.jpg 11KB
C_11.jpg 11KB
C_10.jpg 11KB
C_6.jpg 11KB
C_8.jpg 11KB
C_9.jpg 11KB
A_7.jpg 11KB
C_7.jpg 11KB
C_14.jpg 11KB
A_8.jpg 11KB
C_12.jpg 11KB
A_9.jpg 11KB
C_15.jpg 11KB
A_13.jpg 11KB
C_13.jpg 11KB
A_16.jpg 11KB
A_12.jpg 11KB
A_2.jpg 11KB
17.jpg 11KB
C_16.jpg 11KB
1.jpg 10KB
A_6.jpg 10KB
15.jpg 10KB
9.jpg 10KB
14.jpg 10KB
16_14.jpg 10KB
6.jpg 10KB
2.jpg 10KB
B_5.jpg 10KB
3.jpg 10KB
A_4.jpg 10KB
16_16.jpg 10KB
16_5.jpg 10KB
A_1.jpg 10KB
A_1.jpg 10KB
16_6.jpg 10KB
5.jpg 10KB
16_15.jpg 10KB
10.jpg 10KB
16_2.jpg 10KB
16_12.jpg 10KB
16_1.jpg 10KB
16_13.jpg 9KB
16_3.jpg 9KB
16_7.jpg 9KB
18.jpg 9KB
16_10.jpg 9KB
7.jpg 9KB
16_9.jpg 9KB
16_4.jpg 9KB
8.jpg 9KB
13.jpg 9KB
16_11.jpg 9KB
B_2.jpg 9KB
A_5.jpg 9KB
16_8.jpg 9KB
B_9.jpg 8KB
B_1.jpg 8KB
B_1.jpg 8KB
11.jpg 8KB
B_4.jpg 8KB
B_8.jpg 8KB
16.jpg 8KB
B_11.jpg 8KB
B_14.jpg 8KB
B_12.jpg 7KB
B_13.jpg 7KB
B_6.jpg 7KB
15_1.jpg 7KB
15_11.jpg 7KB
15_15.jpg 7KB
15_5.jpg 7KB
15_4.jpg 7KB
B_15.jpg 7KB
15_9.jpg 7KB
15_2.jpg 6KB
15_16.jpg 6KB
15_6.jpg 6KB
15_13.jpg 6KB
15_7.jpg 6KB
B_16.jpg 6KB
共 374 条
- 1
- 2
- 3
- 4
资源评论
- fengyueqq2013-05-24还行吧,不是我想要的
wanglixiajiangsu
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功