Assign specific RGB colours to 3d mesh/surface/points

后端 未结 1 1441
说谎
说谎 2021-01-23 03:15

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]

相关标签:
1条回答
  • 2021-01-23 04:12

    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:

    mapped parrot

    0 讨论(0)
提交回复
热议问题