From: Ross Anderson on
I have a 128x128 tile-able image that I'd like to tile over a rectangular object defined by 'bounds'. I figured out that if I just want one image, I can say

texture = imread('texture128x128.jpg');
npoints = 128;
[XX YY] = meshgrid(linspace(bounds(1),bounds(2),npoints),linspace(bounds(3),bounds(4),npoints));
ZZ = zeros(size(XX));
surf(XX,YY,ZZ,texture,'FaceColor','texturemap','EdgeColor','none');

But what if I want to tile my image? (it would look better that way, and less pixelated).
Also, say my shape isn't a rectangle. How would I use a square image as a texture for an arbitrary shape?
From: us on
"Ross Anderson" <rpa5nospam(a)cornell.edu> wrote in message <hojc63$bc1$1(a)fred.mathworks.com>...
> I have a 128x128 tile-able image that I'd like to tile over a rectangular object defined by 'bounds'. I figured out that if I just want one image, I can say
>
> texture = imread('texture128x128.jpg');
> npoints = 128;
> [XX YY] = meshgrid(linspace(bounds(1),bounds(2),npoints),linspace(bounds(3),bounds(4),npoints));
> ZZ = zeros(size(XX));
> surf(XX,YY,ZZ,texture,'FaceColor','texturemap','EdgeColor','none');
>
> But what if I want to tile my image? (it would look better that way, and less pixelated).
> Also, say my shape isn't a rectangle. How would I use a square image as a texture for an arbitrary shape?

one of the solutions

img=load('clown');
img=img.X;
[x,y,z]=peaks(64);
surf(x,y,z,img,'facecolor','texturemap','edgecolor','none');
disp('press any key to tile...');
pause;
img=[img,ceil(100*rand(size(img)));ceil(100*rand(size(img))),img];
surf(x,y,z,img,'facecolor','texturemap','edgecolor','none');

us
From: ImageAnalyst on
Ross Anderson:
Sounds like you'd be interested in image quilting:

http://graphics.cs.cmu.edu/people/efros/research/quilting.html

I do have MATLAB code for it, I might be able to share it if you're
interested.
From: Ross Anderson on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <096a9eb8-24d6-4ae1-8223-a08cd3bbc7ee(a)o30g2000yqb.googlegroups.com>...
> Ross Anderson:
> Sounds like you'd be interested in image quilting:
>
> http://graphics.cs.cmu.edu/people/efros/research/quilting.html
>
> I do have MATLAB code for it, I might be able to share it if you're
> interested.

Hmm. Looks like that does quite a bit of image processing, but I think it's too complex for my needs. My image is tile-able and square, so if I had a diagonal rectangle polygon to fit, I could lay a bunch of tiles in a square grid that covers the entire polygon, then crop out those that extend beyond the polygon. But I don't know how to do this yet for a surf defined by a grid of a certain size.

I'll try and play around with the clown code.
From: Ross Anderson on
So looking into what you both have said, I think I can place a nicely tiled image over a solid shape.
But what if I want to surf a collection of shapes with one tiled image? I'm running into a problem.
A good example to demonstrate what I'm going for is a hollow triangle. I can create three sides based on rectangles with semicircles on the ends, then individually surf them, but the tiling doesn't match up at the vertices. If I combine the three collections of points then surf that, I get a filled in triangle, but the tiling works. How can I achieve both?