0

I can programatically generate PLY files with RGB color values as attributes for each vertex, like below

ply
format ascii 1.0
element vertex 126272
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
element face 252540
property list uchar int vertex_index
end_header
-5.38773 -92.173 13.6437 0 0 0
-5.7427 -92.1753 13.6356 0 0 0
-5.10993 -92.1504 13.2691 0 0 0
-5.43053 -92.1653 13.366 0 0 0
-5.75901 -92.1091 13.238 255 0 0
-4.93855 -92.0976 13.0949 255 255 0
-5.32676 -92.0818 12.9526 0 255 0
-5.86176 -92.0882 12.8743 0 255 255
......
3 0 1 3
3 4 3 1
3 0 40 1
3 41 1 40
3 0 3 48
3 0 48 40
3 1 41 49
......

Then I can import the PLY file into Blender (I am using v2.78/79), add a camera (and light and material, etc.), and render it as color images. That works totally fine.

Now I want to change the idea to only generate grayscale images with intensities at each vertex be exactly the value I assign to each vertex in PLY file, like below:

ply
format ascii 1.0
element vertex 126272
property float x
property float y
property float z
property float intensity
element face 252540
property list uchar int vertex_index
end_header
-5.38773 -92.173 13.6437 0
-5.7427 -92.1753 13.6356 -3.5
-5.10993 -92.1504 13.2691 4.2
-5.43053 -92.1653 13.366 2
-5.75901 -92.1091 13.238 -1
-4.93855 -92.0976 13.0949 -2
-5.32676 -92.0818 12.9526 0
-5.86176 -92.0882 12.8743 0.1
......
3 0 1 3
3 4 3 1
3 0 40 1
3 41 1 40
3 0 3 48
3 0 48 40
3 1 41 49
......

What I want to know is, after importing the PLY file to Blender and setting up a camera, what should I do further to let Blender generate a grayscale image that has the exact intensities I assigned at each vertex? I.e. I don't want Blender to change the intensities for me, but I do need it to render several grayscale images from different viewpoints.

Please note that I do have both positive and negative intensities at vertexes. I know these output grayscale images are not easy to be viewed in any image viewer, but that is not an issue for me.

Please kindly help. Thanks!

  • Assuming the vertex colors got imported correctly: Material -> Input -> Vertex Color node outputs - you guessed it - vertex colors. – Frederik Steinmetz Oct 24 '20 at 09:08
  • I do not see the "Input" menu under the "Material" tab. Please refer here https://imgur.com/a/LbZJslX for my screenshot. I am using Blender 2.79b. – John Yang Oct 26 '20 at 17:03
  • in the shader editor: SHIFT A -> Input -> Attribute (there was no node for it yet directly). In the field of the attribute node fill in the name of your vertex colors. If there aren't any, they did not get imported – Frederik Steinmetz Oct 26 '20 at 19:06
  • There must be some extra steps that need to be configured. I already did what you said several times, but no luck - I got some all-black images after clicking the "Animation" button in the "Render" tab. Could you please do it on your computer and verify it? If necessary, you can download the PLY file I have been using from here: https://www.dropbox.com/s/pno9e1nxe6ysndn/lh.pial.ply?dl=0 Thanks! – John Yang Oct 26 '20 at 21:51
  • Blender did not import the vertex colors. I tried in 2.8 as well. Doesn't seem to be implemented. I checked the ply, there is no information about color. There is an attribute called intensity but it ranges from -3 to +3 or something, can't be color. – Frederik Steinmetz Oct 27 '20 at 07:53
  • That's what I want: First, I want the grayscale image, not RGB image. Second, the intensities at each vertex are exactly be given by the intensity values assigned at the PLY file. If there is any way I can change the PLY file to reach the above goal, please advise. – John Yang Oct 27 '20 at 16:13
  • I don't think so. The intensities have negative values, that's not supported by vertex colors. You could normalize them, but you'd still have to write a script to interpret the intensity parameter. Vertex colors are a pain, but it can be done. – Frederik Steinmetz Oct 27 '20 at 17:06
  • Yeah, negative intensities are also what I wanted. Are you 100% sure that vertex color cannot be negative? If so, I will have to give up this effort in this direction:) – John Yang Oct 27 '20 at 17:26
  • Yes, vertex colors are LDR, What's your end goal anyways? Baking the intensities to an actual image might work, but you'd need to unwrap the model (either code or by hand) and you would only get dots where the vertices (UVs) are, no transition. Vertex colors are definetely the way to go, but you will have to stay in the range 0-1 – Frederik Steinmetz Oct 27 '20 at 18:33
  • My goal is to overlay this grayscale image on another image that is also generated by Blender, allowing the users to adjust the overlaying threshold and view with a colormap based on the intensities in the overlaying image - the bigger of the intensities the darker RED (for eample) that part will be displayed with. Since the underlaying image is generated by Blender, I have no control to get the coordinates of those vertexes, because I am also using a camera from different viewpoints. – John Yang Oct 27 '20 at 20:22
  • I was talking about generating an image based on the mesh and the UVs, not in space, like light baking. It't not practicable though, I would recommend normalizing the values, assign them to the Vertex colors (skript) and use that as your mask. If necessary you would 'de-normalze', but I don't really see a reason why. I might be missing something though. – Frederik Steinmetz Oct 28 '20 at 12:55
  • Thanks for your suggestion! But I have no idea how to do that. Could you suggest to me some useful links talking about this? Or give me some samples of your own? – John Yang Oct 28 '20 at 13:52
  • https://blender.stackexchange.com/questions/909/how-can-i-set-and-get-the-vertex-color-property Modify this to read your values. As I said, bit cumbersome, bc. they are not stored per vertex, but per loop. – Frederik Steinmetz Oct 28 '20 at 17:48
  • Great! I will study it. Thanks a lot! – John Yang Oct 28 '20 at 19:02

0 Answers0