matlab总最近邻法则,MATLAB中最近邻插值算法

一段时间后,我在MATLAB Image Processing Toolbox中通过了imresize功能的代码,为图像的最近邻插值创建了一个简化版本。以下是如何应用于您的问题:%# Initializations:scale = [2 2]; %# The resolution scale factors: [rows columns]oldSize = size(in...
摘要由CSDN通过智能技术生成

一段时间后,我在

MATLAB Image Processing Toolbox中通过了

imresize功能的代码,为图像的最近邻插值创建了一个简化版本。以下是如何应用于您的问题:

%# Initializations:

scale = [2 2]; %# The resolution scale factors: [rows columns]

oldSize = size(inputImage); %# Get the size of your image

newSize = max(floor(scale.*oldSize(1:2)),1); %# Compute the new image size

%# Compute an upsampled set of indices:

rowIndex = min(round(((1:newSize(1))-0.5)./scale(1)+0.5),oldSize(1));

colIndex = min(round(((1:newSize(2))-0.5)./scale(2)+0.5),oldSize(2));

%# Index old image to get new image:

outputImage = inputImage(rowIndex,colIndex,:);

另一个选择是使用内置的interp2功能,尽管您提到不想在其中一个注释中使用内置函数。

编辑:解释

如果有人有兴趣,我以为我会解释上面的解决方案如何工作?

newSize = max(floor(scale.*oldSize(1:2)),1);

首先,要获取新的行和列大小,将旧的行和列大小乘以比例因

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值