|
"Wayne King" <wmkingty@gmail.com> wrote in message <hq473s$i4v$1@fred.mathworks.com>...
>
> Hi Mike,
>
> a=256*rand(5);
> b=uint8(a);
> surf(b,'facecolor','texturemap')
>
> Wayne
Hi Wayne,
Thanks for your reply, I tried it and like the mapping idea but the results are not ideal. I think it could work with tweaking, but I'm not sure if any tweaking is possible.
If you look at the way the 2D texture map onto the 3D surface works, the int array "b" is used to create a 5x5 grid of colors. But if you run a surf plot of the 5x5 double array "a", you see that there are really only 4x4 faces, because in general an NxN grid of points only forms an N-1xN-1 grid of cells or squares.
>> a=256*rand(5);
>> b=uint8(a);
>> subplot(1,2,1)
>> surf(a)
>> subplot(1,2,2)
>> surf(b,'facecolor','texturemap')
You end up with an effect where MATLAB tries to lay a 5x5 quilt of colors over a 4x4 surface plot -- the vertices don't match up and it's not very nice.
So, do you know of a way to fix that overlap flaw? I imagine you could do bilinear interpolation on the original grid to get a N-1xN-1 array of values at the center of the cells, but I don't know that you could feed in one array to plot with another for the texture map data. Besides, the extra computation would defeat the purpose of the simplicity and speed I was going for.
|