我有一个图像,其中一些像素被有意地改为零。现在我想做一个双线性插值来找出使用邻域的新像素值,如双线性插值一样。但是,我不想调整图像大小(MATLAB只能使用调整大小功能进行双线性插值)。是否可以在MATLAB中使用插值而不调整图像大小?
是否有可能在MATLAB中进行双线性插值而不调整大小?我读到与双线性内核的卷积可以解决这个问题。你知道这是哪个内核吗?有可能做我想做的事吗?
我有一个图像,其中一些像素被有意地改为零。现在我想做一个双线性插值来找出使用邻域的新像素值,如双线性插值一样。但是,我不想调整图像大小(MATLAB只能使用调整大小功能进行双线性插值)。是否可以在MATLAB中使用插值而不调整图像大小?
是否有可能在MATLAB中进行双线性插值而不调整大小?我读到与双线性内核的卷积可以解决这个问题。你知道这是哪个内核吗?有可能做我想做的事吗?
你可以尝试使用由griddata
支持的选项之一:
griddata(..., METHOD) where METHOD is one of 'nearest' - Nearest neighbor interpolation 'linear' - Linear interpolation (default) 'natural' - Natural neighbor interpolation 'cubic' - Cubic interpolation (2D only) 'v4' - MATLAB 4 griddata method (2D only) defines the interpolation method. The 'nearest' and 'linear' methods have discontinuities in the zero-th and first derivatives respectively, while the 'cubic' and 'v4' methods produce smooth surfaces. All the methods except 'v4' are based on a Delaunay triangulation of the data.
例
% create sample data
[X, Y] = meshgrid(1:10, 1:10);
Z_original = X.*Y;
% remove a data point
Z_distorted = Z_original;
Z_distorted(5, 5) = nan;
% reconstruct
valid = ~isnan(Z_distorted);
Z_reconstructed = Z_distorted;
Z_reconstructed(~valid) = griddata(X(valid),Y(valid),Z_distorted(valid),X(~valid),Y(~valid));
% plot the result
figure
surface(Z_original);
figure
surface(Z_distorted);
figure
surface(Z_reconstructed);
你可能会发现[inplant_nans](https://uk.mathworks.com/matlabcentral/fileexchange/4551-inpaint-nans)有用。而不是0使这些像素NaN,你应该能够使用该功能。 –
非常感谢您的评论。但是,我正在实现一个图像处理方法,要求我使用双三次或双线性插值。您建议的代码是否执行这些插值技术? – mad
不幸的是,我不认为它具有这些具体的方法,我只是用它自己很多的图像插值,它是相当不错的。如果你有这个特定的要求,你可能想看看别的地方。 –