# How can I resample an image in matlab?

7 visualizzazioni (ultimi 30 giorni)
bkshn il 15 Nov 2013
Modificato: bkshn il 16 Nov 2013
Hello
I want to resample an image in matlab. I use imresample code of by Omer Demirkaya. but I have bellow error.
• | |Error using griddedInterpolantSample values must be a single or double array.
Error in interp2/makegriddedinterp (line 214) F = griddedInterpolant(varargin{:});
Error in interp2 (line 135) F = makegriddedinterp(X, Y, V, method,extrap);
Error in imresample (line 49) nimg(:,:,i) = interp2(Ox,Oy,img(:,:,i),Nx,Ny,intmethod);| | *
Could you help me how can I resample an image?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Walter Roberson il 15 Nov 2013
Before you start the interpolation, do
img = im2double(img);
##### 3 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
Walter Roberson il 15 Nov 2013
What happens instead of it "working" ?
bkshn il 16 Nov 2013
Modificato: bkshn il 16 Nov 2013

Accedi per commentare.

### Più risposte (2)

Image Analyst il 15 Nov 2013
Why not simply use imresize()?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Alex Taylor il 15 Nov 2013
The MATLAB interpolation functions require that the inputs be floating point, since interpolation is a floating point operation. Walter's comment is accurate, if you want to interpolate in double precision floating point, im2double will work.
To Image Analyst's point: are you trying to apply a geometric transformation like scaling, rotating, or a generic affine transformation to an image? If so, it would be easier to look at imresize, imrotate, or imwarp if you have the Image Processing Toolbox. These will take care of the resampling for you.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Multirate Signal Processing in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by