matlab - Using meshgrid to interpolate image's physical coordinates -


i new matlab , simulating physical phenomena requires physical coordinates of image. example can use following give dimensions of image.

a = phantom(80,250)  a(81:250,:) = []; 

for physical system, need spacing 2 between each pixel , object go 0:2:280 in x , 0:2:410 in y. trying use meshgrid see if case starting

[x,y] = meshgrid(1:1:100, 1:1:300); [xm,ym] = meshgrid(1:.5:300, 1:.5:450);  m = interp2(x,y,a,xm,ym,'nearest'); 

this not give me want how think can potentially achieve solution.

my basic problem have image size (80,250) , need sample/scale can correlate point on top right location (280mm,410mm) sample of 2mm between each pixel. right approach or should use function?

first of all, image not 80 x 250. sure go checkout documentation.

what hoping after step? determines whether appropriate way go this.

but based on code , last statement, want x range 0 - 280 , y range 0 - 410.

xrange = linspace(0, 280, size(a, 2)); yrange = linspace(0, 410, size(a, 1)); 

so reference coordinates image be

[xx,yy] = meshgrid(xrange, yrange); 

now how want sample you. sounds want every 2mm? let's construct grid sample on.

[xq, yq] = meshgrid(0:2:max(xx(:)), 0:2:max(yy(:))); 

now can our interpolation. important thing remember reference coordinates (x , y) must same size input image (a). 1 of problems initial attempt.

m = interp2(x,y,a,xq,yq,'nearest'); 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -