Note that in the example above, I'm using an indexed color image with an associated colormap. (Note: I think interp2 would be much faster here) Of course with this change, there is no need for the colormap/CDataMapping anymore. 'FaceColor','texturemap', 'EdgeColor','none')Īn alternative to using imresize is explicit interpolation (idea borrowed from CC = ind2rgb(img.X, img.map) %# convert to full truecolorĬ(:,:,i) = griddata(a,b, CC(:,:,i), X,Y, 'linear') Surface(U, V, Z, C, 'CDataMapping','direct'. %# Z-coordinates: I'm using Z=0 for all points, but could be anything %# deformed 2D points (we dont need to know f, just load U/V here) = imresize(img.X, img.map, size(X), 'bicubic') %# initial grid (here 1/5-th the size, but could be anything) Img = load('clown') %# indexed color image Here is an example of texture mapping using the surface function: %# image and 2D grid of points of the same size as the image % sample the texture on the deformed grid % define original grid based on image size Using normalized coordinates makes it easier. Here's some example code showing how to do this with real data. On the other hand, if you want to map the "deformed" texture back to a regularly spaced grid, use griddata: = meshgrid(1:N2,1:M2) To interpolate the original texture at, use: z2 = interp2(x,y,z,u,v) Let's say that the texture samples are in z and you want new samples z2. I think you are asking to get samples of the original texture at.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |