displaying RGB colours using SURF.

I am trying to display a rgb colour map on a gridded surface using surf.
I have grids of each rgb colour. How do I combine to give the surf(x,y,z,C)?
thanks

댓글 수: 6

Sian Allerton
Sian Allerton 2020년 12월 28일
thanks all, solved. Created C as nx,ny,3(rgb) matrix.
Image Analyst
Image Analyst 2020년 12월 28일
For the benefit of others, could you provide a small demo?
I'm attaching mine (which is based Bruno's method below).
Ameer Hamza
Ameer Hamza 2020년 12월 29일
It should be "based on Ameer's method" :P
the issue was how to structure an image variable. i wasn't starting from an image, but a set of rgb points.
% x,y,z point cloud poitions in temp(:,1:3)
% rgb levels for points in temp(:,4:6)
% first grid the point data and the colour data.
x = temp(:,1);
y = temp(:,2);
z = temp(:,3);
%define grid
xmax = max(x);
xmin = min(x);
ymax = max(y);
ymin = min(y);
n = 1000;
m = 1000;
xs = (xmax-xmin)/n;
ys = (ymax-ymin)/m;
[gx,gy]= meshgrid(xmin:xs:xmax,ymin:ys:ymax);
gz = griddata(x,y,z,gx,gy);
gr = griddata(x,y,temp(:,4),gx,gy, "nearest");% red
gg = griddata(x,y,temp(:,5),gx,gy, "nearest");% green
gb = griddata(x,y,temp(:,6),gx,gy, "nearest");% blue
gc(:,:,1) = gr; % red
gc(:,:,2) = gg; % green
gc(:,:,3) = gb; % blue
%normalise colours
gcc= gc/256;
surf(gx,gy,gz,gcc);
Thanks for everyone's comments. The image is of a Scottish hill fort from drone data btw.
Walter Roberson
Walter Roberson 2020년 12월 29일
I suggest using warp()
Image Analyst
Image Analyst 2020년 12월 29일
Sorry Ameer, you're absolutely right. Sometimes I work on too many problems too close together. I must have gotten confused.

댓글을 달려면 로그인하십시오.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 12월 27일

0 개 추천

You can use texture mapping to display an RGB image on a surface(). See here: https://www.mathworks.com/matlabcentral/answers/91858-is-it-possible-to-perform-texture-mapping-within-matlab. For example
img = imread('pears.png');
z = peaks(100);
surf(z, ...
'FaceColor','texturemap',...
'EdgeColor','none',...
'Cdata',img)
view(3)

카테고리

도움말 센터File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

태그

질문:

2020년 12월 27일

댓글:

2020년 12월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by