View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Image Resize

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

2.0
2.0 | 3 ratings Rate this file 10 Downloads (last 30 days) File Size: 1.39 KB File ID: #30787 Version: 1.0
image thumbnail

Image Resize

by

 

Another function to resize an image.

| Watch this File

File Information
Description

IMAGERESIZE able to resize an image. You can downsize and also upsize an image using scaling factor.

This is a simple implementation of matlab IMRESIZE code.

Nothing new about this code.

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
15 Jul 2016 DGM

Yes, using a loop without preallocation means this is terribly slow for what should be the most simple interpolation method (nearest-neighbor).

While simplicity has its place, people looking for a image-resizing tool outside of the Image Processing Toolbox shouldn't think that this reflects the approach used by IMRESIZE.

A faster and more flexible IMRESIZE alternative would be to use INTERP2().

%%%%%%%%%%%%%%
%% set axis scaling
xscale=3
yscale=3

sz=size(img_in);
numchans=size(img_in,3);
yy=linspace(1,sz(1),ceil(sz(1)*yscale));
xx=linspace(1,sz(2),ceil(sz(2)*xscale));

img_out=zeros([ceil(sz(1:2).*[yscale xscale]) 3]);
for c=1:numchans
img_out(:,:,c)=interp2(img_in(:,:,c),xx',yy,'bilinear');
end
%%%%%%%%%%%%%%

This will work on images with any number of channels, and can use different interpolation methods. It also doesn't require any IPT functions.

That's not to imply that my suggested code replicates IMRESZE behavior either.

Comment only
24 Jan 2016 Samet Taspinar

for loop is not a good idea in matlab, please try vectorizing it.

10 Oct 2014 Wetch

Wetch (view profile)

 
25 Sep 2012 Dung Luong  
13 Mar 2012 Grzegorz Knor

Please pre-allocate the img_out variable to speed up your code.

Comment only

Contact us