From: Michael on 13 Apr 2010 17:41 I have encountered contradictory errors while trying to perform a surf plot on non-double datatypes. Example code: >> a=256*rand(5); >> b=uint8(a); surf(b) Warning: CData must be double or single unless it is used only as a texture data Warning: CData must be double or single unless it is used only as a texture data >> c=single(a); surf(c) Warning: CData must be double or uint8. Warning: CData must be double or uint8. >> d=double(a); surf(d) % no errors on this command, surf(d) works fine >> So, given a 5x5 array in various data formats, MATLAB does the following: 1) Claims it can't surf plot a uint8 array because it requires either single or double 2) Claims it can't surf plot a single array because it requires either uint8 or double 3) Plots double format just fine, as expected Does anyone have any insight into this? My main questions are: Q1) Why the contradictory errors between the attempt at surf plotting a uint8 array vs. a single array? Q2) Is there a way to surf plot a data format with less memory footprint than required for double arrays? FYI, my application is video image processing with tens of thousands of frames. The data is all uint16 and I'd like to be able to work with less memory overhead. Thanks, Mike
From: Wayne King on 14 Apr 2010 06:58 "Michael " <mcdon06(a)umich.edu> wrote in message <hq2odg$k3o$1(a)fred.mathworks.com>... > I have encountered contradictory errors while trying to perform a surf plot on non-double datatypes. Example code: > > >> a=256*rand(5); > >> b=uint8(a); surf(b) > Warning: CData must be double or single unless it is used only as a texture data > Warning: CData must be double or single unless it is used only as a texture data > >> c=single(a); surf(c) > Warning: CData must be double or uint8. > Warning: CData must be double or uint8. > >> d=double(a); surf(d) % no errors on this command, surf(d) works fine > >> > > So, given a 5x5 array in various data formats, MATLAB does the following: > > 1) Claims it can't surf plot a uint8 array because it requires either single or double > 2) Claims it can't surf plot a single array because it requires either uint8 or double > 3) Plots double format just fine, as expected > > Does anyone have any insight into this? My main questions are: > > Q1) Why the contradictory errors between the attempt at surf plotting a uint8 array vs. a single array? > Q2) Is there a way to surf plot a data format with less memory footprint than required for double arrays? > > FYI, my application is video image processing with tens of thousands of frames. The data is all uint16 and I'd like to be able to work with less memory overhead. > > Thanks, > Mike Hi Mike, a=256*rand(5); b=uint8(a); surf(b,'facecolor','texturemap') Wayne
From: Michael on 14 Apr 2010 10:04 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hq473s$i4v$1(a)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.
|
Pages: 1 Prev: code for function equality Next: Remove duplicates from a vector |