资源简介
本代码使用多相位插值法实现图像缩放,实际上在4 x 4领域大小内进行多相位插值和三次插值几乎是一样的,只是对应插值函数值略微不同。多相位插值法是通过对输出点对应原图中的领域进行Lanczos2 函数移相插值来产生输出点的。
代码片段和文件信息
%Polyphase scaler算法(该算法采用Lanczos2算法)
%Taps_H=4
%Taps_V=4
%Phase_H=4
%Phase_V=4
clear all;
A = imread(‘test_edge3.bmp‘);
A = double(A);
A = rgb2yuv(A);
imgA = uint8(A);
% interpolation scaler
Hm = 640;
Hd = 3840;
Vm = 480;
Vd = 2160;
[mn] = size(A(::1)); %get the length and width
A(::1) = A(::1);
for j=1:n
if(mod(j2)==0)
A(:j2) = A(:j-12);
A(:j3) = A(:j-13);
else
A(:j2) = A(:j2);
A(:j3) = A(:j3);
end
end
k = m*Vd/Vm;
l = n*Hd/Hm;
w33 = [-1/8 -1/8 -1/8;
-1/8 1 -1/8;
-1/8 -1/8 -1/8];
B = zeros(34); %horizotal interpolation
C = zeros(kl3);
%%%%%%%%%%%% xilinx v_scaler.pdf %%%%%%%%%%%%%%%%%%%%%%%%
%% Subsample a Sinc function and create 2D array
%num_h_taps = 4;
%num_v_taps = 4;
%num_taps = 4;
%num_phases = 8;
%coef_width = 16;
%x=-(num_taps/2):1/num_phases:((num_taps/2)-1/num_phases);
%COE_y=2*(sin(pi*x).*sin(pi*x/2))./(pi^2*x.^2);
%coefs_2d=reshape(sinc(x) num_phases num_taps)
format long
% Normalize each phase individually
%for i=1:num_phases
% sum_phase = sum(coefs_2d(i:));
% for j=1:num_taps
% norm_phases(i j) = coefs_2d(i j)/sum_phase;
% end
% % Check - Normalized values should sum to 1 in each phase
% norm_sum_phase = sum(norm_phases(i:))
%end
%% Translate real to integer values with precision defined by coef_width
%int_phases = round(((2^(coef_width-2))*norm_phases))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j = 1 : l
Hi = j*Hm/Hd;
xHi = double(uint16(Hi));%整数部分
u = Hi - xHi; %小数部分
% u = floor(j*Hm./Hd); %取余运算
for i= 1 : k
Vi = i*Vm/Vd;
xVi = double(uint16(Vi));%整数部分
v = Vi - xVi; %小数部分
% v = floor(i*Vm./Vd); %取余运算
if( (uint16(xHi) < n-4) & (uint16(xVi) < m-4) & (uint16(xHi) > 1) & (uint16(xVi) > 1))
src44 = [A(uint16(xVi-1)uint16(xHi-1)1) A(uint16(xVi-1)uint16(xHi )1) A(uint16(xVi-1)uint16(xHi+1)1) A(uint16(xVi-1)uint16(xHi+2)1);
A(uint16(xVi )uint16(xHi-1)1) A(uint16(xVi )uint16(xHi )1) A(uint16(xVi )uint16(xHi+1)1) A(uint16(xVi )uint16(xHi+2)1);
A(uint16(xVi+1)uint16(xHi-1)1) A(uint16(xVi+1)uint16(xHi )1) A(uint16(xVi+1)uint16(xHi+1)1) A(uint16(xVi+1)uint16(xHi+2)1);
A(uint16(xVi+2)uint16(xHi-1)1) A(uint16(xVi+2)uint16(xHi )1) A(uint16(xVi+2)uint16(xHi+1)1) A(uint16(xVi+2)uint16(xHi+2)1);];
src_u = [A(uint16(xVi-1)uint16(xHi-1)2) A(uint16(xVi-1)uint16(xHi )2) A(uint16(xVi-1)uint16(xHi+1)2) A(uint16(xVi-1)uint16(xHi+2)2);
A(uint16(xVi )uint16(xHi-1)2) A(uint16(xVi )uint16(xHi )2) A(uint16(xVi )uint16(xHi+1)2) A(uint16(xVi )uint16(xHi+2)2);
A(uint16(xVi+1)uint16(xHi-1)2) A(uint16(xVi+1)uint16(xHi )2) A(uint16(xVi+1)uint
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
- Matlab锁相环仿真-Phase Locked Loop.rar
评论
共有 条评论