【发布时间】:2017-05-06 19:41:25
【问题描述】:
我知道 MATLAB 中的imresize 会将图像I1 调整为I2 并按比例缩放。有没有办法知道原始图像中的像素和调整大小的图像之间的关联?例如,是否存在一些映射?
最重要的是,请考虑性能。
【问题讨论】:
我知道 MATLAB 中的imresize 会将图像I1 调整为I2 并按比例缩放。有没有办法知道原始图像中的像素和调整大小的图像之间的关联?例如,是否存在一些映射?
最重要的是,请考虑性能。
【问题讨论】:
最简单的方法就是乘以比例因子(或除以找到以前的坐标):
% read image and generate several coordinates to plot on
im = imread('lena.jpg');
[x,y] = meshgrid(100:100:450);
x = x(:); y = y(:);
% scale of resizing
scale = 0.4;
% plot original image
subplot(131);
imshow(im);
hold on;
plot(x,y,'xr','LineWidth',2,'MarkerSize',15);
title(sprintf('Original, size = [%d,%d]',size(im,1),size(im,2)));
% resize to obtain smaller image
imSmall = imresize(im,scale);
subplot(132);
imshow(imSmall);
hold on;
% plot scaled coordinates
plot(x.*scale,y.*scale,'xr','LineWidth',2,'MarkerSize',15);
title(sprintf('Small, size = [%d,%d]',size(imSmall,1),size(imSmall,2)));
% resize to obtain larger image
imBig = imresize(im,1/scale);
subplot(133);
imshow(imBig);
hold on;
% plot scaled coordinates
plot(x./scale,y./scale,'xr','LineWidth',2,'MarkerSize',15);
title(sprintf('Big, size = [%d,%d]',size(imBig,1),size(imBig,2)));
【讨论】: