将特定的RGB颜色分配给3d网格/曲面/点 [英] Assign specific RGB colours to 3d mesh/surface/points

查看:364
本文介绍了将特定的RGB颜色分配给3d网格/曲面/点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

脸孔和地标地标



我有一张脸部图片,其上贴有脸部特征。图像以标准JPEG格式存储,标记以 [xy] 格式存储(点的x,y对应于图像上的坐标,如下所示) p>






插值的3d面网格



我已经为每个标签生成了深度信息点,并且具有 [xyz] 格式的矩阵,其中坐标x和y与点的坐标相同。



稀疏网格看起来像这样:



然后我插入 xrange yrange zrange 以获得更好的网格。使用 mesh(xrange,yrange,zrange)给我以下



面部图像像素的颜色可以使用 imread(face_image.jpg)
考虑到每个内插点的(x,y)值对应于图像中的(x,y),可以使像素的颜色为(x,y,z

解决方案

我会建议这样:

  n = 50000; %选择适当的东西
[C,map] = rgb2ind(FaceImageRGB,n);

将RGB图像中的颜色映射到线性索引。 请确保网格和RGB图片具有相同的xy尺寸



然后使用 surf 绘制带有索引颜色值的表面(应该是 surf(X,Y,Z,C)

$

 作为颜色图。

  
colormap(map);

编辑:一个工作示例em> image this time ...):

  rgbim = imread('http://upload.wikimedia.org/wikipedia /commons/0/0d/Loriculus_vernalis_-Ganeshgudi,_Karnataka,_India_-male-8-1c.jpg'); 

n = 50000; %choose something apropriate
[C,map] = rgb2ind(rgbim,n);

%创建与图像尺寸相同的网格:
[X,Y] = meshgrid(-floor(size(rgbim,2)/ 2):floor ,2)/ 2),-floor(size(rgbim,1)/ 2):floor(size(rgbim,1)/ 2));

%Z的任意函数:
Z = - (X. ^ 2 + Y. ^ 2);

%将图像显示为颜色值:
surf(X,Y,Z,double(C)),阴影平面
colormap

结果:




Face and feature landmarks

I have a face image that has labelled face features. The image is stored in standard JPEG format and the landmarks are stored in [x y] format (x,y of point corresponds to its coordinates on the image as shown below)


Interpolated 3d face mesh

I have generated depth information (a 3d mesh) for each of the labelled points, and have a matrix in [x y z] format, where the coordinates x and y are the same as that of the points.

The sparse mesh looks like this:

I then interpolated over xrange, yrange and zrange to get a better mesh. Using mesh(xrange,yrange,zrange) gives me the following

The colours for face image pixels can be obtained using imread(face_image.jpg). Given that the (x,y) value of each of the interpolated point corresponds to (x,y) in the image, is it possible to make the colour of the pixel at (x,y,z)[3dmesh] the same as colour of (x,y)[face image]?

This would effectively superimpose/warp the face on the3d mesh, giving me a 3d face model.

解决方案

I would suggest this:

n=50000; % chose something appropriate
[C,map] = rgb2ind(FaceImageRGB,n);

To map the color in your RGB image into a linear index. Make sure the mesh and the RGB image have the same x-y dimensions.

Then use surf to plot the surface with the indexed values for color (should be in the form surf(X,Y,Z,C)) and the map as color map.

surf(3dmesh, C), shading flat;
colormap(map);

Edit: a working example (with a colorful image this time...):

rgbim=imread('http://upload.wikimedia.org/wikipedia/commons/0/0d/Loriculus_vernalis_-Ganeshgudi,_Karnataka,_India_-male-8-1c.jpg');

n=50000; % chose something apropriate
[C,map] = rgb2ind(rgbim,n);    

% Creation of mesh with the same dimensions as the image:
[X,Y] = meshgrid(-floor(size(rgbim, 2)/2):floor(size(rgbim, 2)/2), -floor(size(rgbim, 1)/2):floor(size(rgbim, 1)/2));

% An arbitrary function for Z:
Z=-(X.^2+Y.^2);

% Display the surface with the image as color value:
surf(X, Y, Z, double(C)), shading flat
colormap(map);

Result:

这篇关于将特定的RGB颜色分配给3d网格/曲面/点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆