图像放大有很多算法,我不知道你需要哪种。可以用 matlab 自己带的函数实现。
比如下面的函数是对输入图像 x 做放大,放大倍数是 factor,放大方法(就是内插方法)是 mode、可以是
'cubic', 'linear'等.
调用方法是
F = MyInterp2(x, 2, 'cubic');
function result = MyInterp2(x, factor, mode)
%x input data
%factor size of zoom
%mode the mode of interpolation
[nRowLR, nColumnLR] = size(x);
nRowHR = nRowLR * factor;
nColumnHR = nColumnLR * factor;
[X_LR, Y_LR] = meshgrid(1:factor:nColumnHR, 1:factor:nRowHR);
[X_HR, Y_HR] = meshgrid(1:nColumnHR, 1:nRowHR);
result = interp2(X_LR, Y_LR, x, X_HR, Y_HR, mode);
result(isnan(result))=0;
评论0