function c = mefcv2(x,N1,N2,ns,nag)
% mefcv2 - 2D forward mirror-extended curvelet transform
% -----------------
% INPUT
% --
% x is an N1-by-N2 matrix.
% --
% N1, N2 are positive integers.
% --
% ns is the number of levels, including the coarsest level. ns =
% ceil(log2(min(N1,N2)) - 3) is commonly used.
% --
% nag. 2*pi/nag is the size of the spanning angle of each wedge.
% nag is required to be a multiple of 8 and nag = 16 is often used.
% -----------------
% OUTPUT
% --
% c is a cell array which contains the curvelets coefficients. If
% tp=='ortho', then c{j}{l}(n1,n2) is the coefficient at scale j,
% direction l and spatial index (n1,n2). The directional index l
% iterates through the wedges in the first quadrant. Notice that, for
% the mirror-extended wave atoms, the spatial indices wrap around once.
% -----------------
% Written by Lexing Ying and Laurent Demanet, 2007
if(mod(nag,4)~=0)
error('wrong');
end
%1. dct
fd = dct2(x);
%2. scatter
E1 = ceil(N1/3); E2 = ceil(N2/3); %E1 = 0; E2 = 0;
fd = mescatter(fd,E1);
fd = mescatter(fd',E2)';
A1 = size(fd,1); A2 = size(fd,2);
G1 = 4/3*N1; G2 = 4/3*N2;
c = cell(ns,1);
ttl = 0;
for s=ns:-1:2
%get ring
R1 = 2^(s-ns)*G1;
R2 = 2^(s-ns)*G2;
idx1 = [ceil(-R1):floor(R1)];
[wl,wr] = cvwindow((idx1+R1/1)/(R1/2)); tmpa = wl;
[wl,wr] = cvwindow((idx1-R1/2)/(R1/2)); tmpb = wr;
coef1 = tmpa.*tmpb;
idx2 = [ceil(-R2):floor(R2)];
[wl,wr] = cvwindow((idx2+R2/1)/(R2/2)); tmpa = wl;
[wl,wr] = cvwindow((idx2-R2/2)/(R2/2)); tmpb = wr;
coef2 = tmpa.*tmpb;
lowpass = coef1'*coef2;
idx1 = [ceil(-R1):floor(R1)];
[wl,wr] = cvwindow((idx1+R1/2)/(R1/4)); tmpa = wl;
[wl,wr] = cvwindow((idx1-R1/4)/(R1/4)); tmpb = wr;
coef1 = tmpa.*tmpb;
idx2 = [ceil(-R2):floor(R2)];
[wl,wr] = cvwindow((idx2+R2/2)/(R2/4)); tmpa = wl;
[wl,wr] = cvwindow((idx2-R2/4)/(R2/4)); tmpb = wr;
coef2 = tmpa.*tmpb;
tmppass = coef1'*coef2;
hghpass = sqrt(1-tmppass.^2);
pass = lowpass.*hghpass;
[M1,M2] = size(pass);
fh = zeros(M1,M2);
fh(mod(idx1,M1)+1,mod(idx2,M2)+1) = pass .* fd(mod(idx1,A1)+1,mod(idx2,A2)+1);
%ggg = ggg + norm(fh(:))^2;
nbangles = nag*2^(ceil((s-2)/2));
%c{s} = fcv2_sepangle(R1,R2,fh,nbangles);
%---------
[M1,M2] = size(fh);
nd = nbangles/4;
cs = cell(nd,1);
W1 = 2*R1/nd; W2 = 2*R2/nd;
%take only first quadrant
cnt = 1;
for g=nd/2:nd-1
xs = R1/4-(W1/2)/4; xe = R1;
ys = -R2 + (2*g-1)*W2/2; ye = -R2 + (2*g+3)*W2/2;
xn = ceil(xe-xs); yn = ceil(ye-ys);
if(g==0)
thts = atan2(-1.0, 1.0-1.0/nd);
thtm = atan2(-1.0+1.0/nd, 1.0);
thte = atan2(-1.0+3.0/nd, 1.0);
elseif(g==nd-1)
thts = atan2(-1.0+(2.0*g-1.0)/nd, 1.0);
thtm = atan2(-1.0+(2.0*g+1.0)/nd, 1.0);
thte = atan2(1.0, 1.0-1.0/nd);
else
thts = atan2(-1.0+(2.0*g-1.0)/nd, 1.0);
thtm = atan2(-1.0+(2.0*g+1.0)/nd, 1.0);
thte = atan2(-1.0+(2.0*g+3.0)/nd, 1.0);
end
%fprintf(1,'%d %d %d\n',thts,thtm,thte);
R21 = R2/R1;
wpdata = zeros(xn,yn);
for xcur=ceil(xs):xe
yfm = ceil( max([-R2, R21*xcur*tan(thts)]) );
yto = floor( min([R2, R21*xcur*tan(thte)]) );
ycur = yfm:yto;
thtcur = atan2(ycur/R2,xcur/R1);
[al,ar] = cvwindow((thtcur-thts)/(thtm-thts));
[bl,br] = cvwindow((thtcur-thtm)/(thte-thtm));
pou = al.*br;
wpdata(mod(xcur,xn)+1,mod(ycur,yn)+1) = fh(mod(xcur,M1)+1,mod(ycur,M2)+1) .* pou;
end
cs{cnt} = ifft2(wpdata) * sqrt(numel(wpdata)); ttl = ttl + norm(cs{cnt}(:))^2;
cnt = cnt+1;
end
for f=nd-1:-1:nd/2
ys = R2/4-(W2/2)/4; ye = R2;
xs = -R1 + (2*f-1)*W1/2; xe = -R1 + (2*f+3)*W1/2;
xn = ceil(xe-xs); yn = ceil(ye-ys);
if(f==0)
phis = atan2(-1.0, 1.0-1.0/nd);
phim = atan2(-1.0+1.0/nd, 1.0);
phie = atan2(-1.0+3.0/nd, 1.0);
elseif(f==nd-1)
phis = atan2(-1.0+(2.0*f-1.0)/nd, 1.0);
phim = atan2(-1.0+(2.0*f+1.0)/nd, 1.0);
phie = atan2(1.0, 1.0-1.0/nd);
else
phis = atan2(-1.0+(2.0*f-1.0)/nd, 1.0);
phim = atan2(-1.0+(2.0*f+1.0)/nd, 1.0);
phie = atan2(-1.0+(2.0*f+3.0)/nd, 1.0);
end
%fprintf(1,'%d %d %d\n',phis,phim,phie);
R12 = R1/R2;
wpdata = zeros(xn,yn);
for ycur=ceil(ys):ye
xfm = ceil( max([-R1, R12*ycur*tan(phis)]) );
xto = floor( min([R1, R12*ycur*tan(phie)]) );
xcur = xfm:xto;
phicur = atan2(xcur/R1, ycur/R2);
[al,ar] = cvwindow((phicur-phis)/(phim-phis));
[bl,br] = cvwindow((phicur-phim)/(phie-phim));
pou = al.*br;
wpdata(mod(xcur,xn)+1,mod(ycur,yn)+1) = fh(mod(xcur,M1)+1,mod(ycur,M2)+1) .* pou';
end
cs{cnt} = ifft2(wpdata) * sqrt(numel(wpdata)); ttl = ttl + norm(cs{cnt}(:))^2;
cnt = cnt+1;
end
c{s} = cs;
%fprintf(1,'%d %d\n', ttl, ggg/4);
end
%do the first level
if(1)
s = 1;
R1 = 2^(s-ns)*G1;
R2 = 2^(s-ns)*G2;
idx1 = [ceil(-R1):floor(R1)];
[wl,wr] = cvwindow((idx1+R1/1)/(R1/2)); tmpa = wl;
[wl,wr] = cvwindow((idx1-R1/2)/(R1/2)); tmpb = wr;
coef1 = tmpa.*tmpb;
idx2 = [ceil(-R2):floor(R2)];
[wl,wr] = cvwindow((idx2+R2/1)/(R2/2)); tmpa = wl;
[wl,wr] = cvwindow((idx2-R2/2)/(R2/2)); tmpb = wr;
coef2 = tmpa.*tmpb;
pass = coef1'*coef2;
[M1,M2] = size(pass);
fh = zeros(M1,M2);
fh(mod(idx1,M1)+1,mod(idx2,M2)+1) = pass .* fd(mod(idx1,A1)+1,mod(idx2,A2)+1); %ggg = ggg + norm(fh(:))^2;
cs = cell(1,1);
K1 = M1+1; K2 = M2+1;
tmp = zeros(K1,K2);
tmp(mod(idx1,K1)+1,mod(idx2,K2)+1) = fh(mod(idx1,M1)+1,mod(idx2,M2)+1);
tmp = mecombine(tmp,0);
tmp = mecombine(tmp',0)';
tmp = tmp/4;
cs{1} = ifft2(tmp) * sqrt(numel(tmp)); ttl = ttl + norm(cs{1}(:))^2;
c{s} = cs;
%fprintf(1,'%d\n', ttl);
end

朱moyimi
- 粉丝: 86
- 资源: 1万+
最新资源
- 基于qt设计的的银行管理系统,包含报告ppt,cpp期末课设.zip
- Comsol仿真等离子体空气反应框架:无模型化处理,氧气氮气氦气详细反应模拟,碰撞截面查询及迁移率扩散系数解析,反应选择与参数求解系统,无模型Comsol仿真等离子体空气反应框架:氧气、氮气、氦气详细
- 基于SpringBoot+Mybatis+Vue设计的在线选课系统。其中实现了学生选课,教师管理成绩,课程管理和选课管理等功能。.zip
- 基于Matlab GUI界面的模糊车牌识别系统:深度融合维纳滤波与卷积神经网络的字符识别策略,基于卷积神经网络的模糊车牌识别系统设计与实现-涉及Matlab GUI界面及多步骤数字图像处理技术,-
- 基于Vue和JavaScript的GreencityLDZBruoyi-UI城市园林资源一张图设计源码
- 毕设,基于unity+c#设计的一个像素风解谜游戏,解谜部分是复刻了编程游戏TIS-100,整个项目实现了主要的功能模块。可以直接使用现有的模块制作一个新的剧情。.zip
- 基于SpringBoot设计的的新闻管理发布系统.zip
- 通信系统综合设计,基于Pyqt进行了x光和CT的识别与分割,将OpenCV competition 的作品修改为了纯python语言.zip
- 初级面试整理,面试题整理
- 基于多算法的车辆路径规划与优化研究:考虑时间窗及各类需求的物流选址策略,基于多算法的车辆路径规划与优化问题研究:带时间窗的VRPTW问题及物流选址策略分析,车辆路径规划vrp,车辆路径优化,MATLA
- 基于疾病为中心的医药领域知识图谱构建与自动问答系统设计源码
- QT单人大作业.zip
- 基于qt c++设计的一个即时通讯软件.zip
- 安卓项目,拥有个人信息管理、书签管理、连环画观看等功能.zip
- 基于Java、HTML、JavaScript、CSS的医院住院处管理系统设计源码
- 基于CNN的化学物质识别.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


