# 3D intensity map for grayscale image

I've got images of blood drops in grayscale and I want to generate 3D data where the first two dimensions represent the area of interest and the 3rd dimension represents the pixel intensity of that area. Here's an example image:

My requirement is as shown in D,E,F while the raw images are A,B,C. Also, what algorithms can be used for detection of the plateau areas as detected in G,H,I?

• Matlab? Python? – Maurits Mar 22 '15 at 15:29
• @Maurits I actually need to do this in Java but you can answer using MATLAB code. I'll do the porting myself. – Abdul Fatir Mar 22 '15 at 15:31
• Matlab has build in commands for this (surf) so porting will be hard. Also, make a separate question for the second part – Maurits Mar 22 '15 at 15:37

If all you are looking to do is to take the 2D grayscale image and turn it into a 3D representation for visualisation purposes, then perhaps you could consider a function that accepts the image and produces a VRML (or X3D) string describing your 3D model. That model would then be passed to a standard java graphics toolkit (for example Java 3D) which would handle the rendering for you.

Here is a simplistic example: For the 2x2 grayscale image of X = [0,1;1,0], your VRML indexedFace node would look like this:

IndexedFaceSet {
coord Coordinate {
point [-1 1 x(0,0), 1 1 x(0,1), 1 -1 x(1,1), -1 -1 x(1,0)]
}
coordIndex [ 0 1 2 3 ]   # That is, just one face
}
`

In the above snippet, "x(i,j)" is a placeholder for the corresponding value from the image (which will be formated to the actual number) and as you can see it represents the Z dimension of your indexedFaceSet.

Actually, the structure of "point" is just a list (in row major order) of all of you image points, which is very easy to generate by iterating through all pixels of the image. Similarly, the structure of coordIndex is also set to quads (faces defined by 4 points in space) which map to the image's grid. The indexedFaceSet provides capabilities to define the colour of each vertex (each defining point of the face) as well in a way similar to the way "point" is defined.