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

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

问题描述

我有一张标有面部特征的面部图像.图像以标准JPEG格式存储,地标以[x y]格式存储(点的x,y对应其在图像上的坐标,如下所示)

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)

我为每个标记点生成了深度信息(一个 3d 网格),并有一个 [xyz] 格式的矩阵,其中坐标 x 和 y 与点.

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.

稀疏网格如下所示:

然后我对 xrangeyrangezrange 进行插值以获得更好的网格.使用 mesh(xrange,yrange,zrange) 给我以下内容

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

人脸图像像素的颜色可以使用imread(face_image.jpg)获得.鉴于每个插值点的(x,y)值对应于图像中的(x,y),是否可以使(x,y,z)[3dmesh]处的像素的颜色(x,y)[人脸图像]的颜色一样吗?

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]?

这将有效地在 3d 网格上叠加/扭曲人脸,给我一个 3d 人脸模型.

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

推荐答案

我建议:

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

将 RGB 图像中的颜色映射到线性索引.确保网格和 RGB 图像具有相同的 x-y 尺寸.

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.

然后使用 surf 绘制带有颜色索引值的表面(应采用 surf(X,Y,Z,C) 形式)和 map 作为颜色图.

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);

一个工作示例(这次使用彩色图像...):

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);

结果:

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

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