Shape-from-Shadow accessory
-
I thought this might be a useful tool for anyone working on grayscale heightmap-to-mesh conversions, in SketchUp with a Ruby or in any of the many programs that already have this capability.
http://www.geocities.com/alreaud/gimp_plug-in/shapefs.html
In case you don't know, here's a decent explanation of what "shape from shadow" does, written by a truly gifted crackpot (his science here is sound, but I think he is a little rabid about the topic of intelligent life on Mars):
http://www.newfrontiersinscience.com/martianenigmas/Articles/SFS/sfs.html
Basically, if you have a grayscale photo of something, and you know how far away it is and you know where the sun was when the picture was taken, you can use this piece of software to create a true heightmap of the photographed subject (a heightmap is just a fancy way of saying that what is closer to the camera is lighter than what is far away). And that heightmap can be turned into a 3D computer model. This is how NASA generates those 3D terrains of Mars that you sometimes find on the web.
This shape-from-shadow plugin is a very elaborate addition to the GIMP, a free program very similar to a primitive version of Photoshop that is available for most computer systems.
To do the shape-from-shadow dance properly, then, you will need to download and install the GIMP on your computer and either install (if you have Windows) or compile/install the plugin (if you have Linux or Mac).
Have fun.
--Lewis
[Lewis Wadsworth]
-
Hi Lewis,
I belive there's already something like that as a ruby plugin on Didier's page: "heightfield_gen.rb". It can be used for meshes Look at here:
http://www.crai.archi.fr/RubyLibraryDepot/Ruby/em_geo_page.htmGai...
-
No, shape from shadow (SFS)is much more intelligent than that ruby.
Look at this face. The tip of the nose is just as white as the cheeks. Both sides of the nose are dark, shaded. With a white is higher, darker is lower algoritm this would not look like a face at all. An SFS algoritm does actually recover the face shape. In this case the light source is near the camera. In ordinary lighting conditions the nose would probably have one lighter side and a large shadow over the the other cheek. Heightfield can't understand that, SFS can.
BTW is Didier is listening: I tried the ruby and it seems to be as dead as a doornail. It does show a ppm file open dialog, I did translate this face into PPM for the occasion, then it asks for some numbers, I use the defaults, SU stays empty.
I've not yet tried the SFS software from this link, I do own a 3D camera that works in a similar way.
[Maggy]
-
Thanks Maggy, I understand the difference now.
Actually I only used the ruby plugin once myself, too and without success but I thought that I screwed something up and left it without trying more. -
I did not have any luck with the heightmap Ruby for SketchUp either, but since almost every other modeler out has a decent heightmap capability it has not been a problem. I particularly like Rhino's two heightmap tools (one generates NURBS, one is for meshes).
The issue for me has generally been the creation of a heightmap that represents a real object from a standard photographic image, and that's where this SFS for the GIMP seems promising.
I haven't tried this tool either, although I do use the GIMP regularly...but it's on my list of things to experiment with right after I work out a different way of pulling terrain models from GE than is implemented in SketchUp. (I have voluntarily exiled myself from commercial operating systems for private work, as part of an experiment to see if I can create an equivalent digital tool set for architectural design on the Linux platform.) If anyone reading this gets a chance to work with SFS before I do, I would love it if you would post the results here.
--Lewis
[Lewis Wadsworth]
-
It depends on what you call a "standard photographic image"? If you:
-cover your subject and background in flour
-use only one and exclude all other light sources
-record camera distance, angle, lens type, aperture
-record light source distance and angle
SFS will work perfectlyIf you want to use a picture like this one, how could the software possibly see the difference between shading, dress pattern, dogs and so on?
For example radar images or monochromatic laser scans are ideal for SFS.
[Maggy]
-
@maggy said:
It depends on what you call a "standard photographic image"?
I should have been clearer...my apologies. My "standard photographic image" is usually an architectural photograph taken with a documented tilt-shift lens. Making such things used to be one of my side professions.
However, SFS is typically used for aerial or satellite photography, as I understand it.
--Lewis
[Lewis Wadsworth]
-
Although there've been publications about SFS in the eighties, the practical use is still rare.
[Maggy]
-
Hi Maggy,
I'm listening... and noticed than you probably never read the small tuto about heightfield_gen. It's strange to see that users who complain about uselessness of scripts or say they don't work never read the dox.
OF COURSE it has NOT been developed for SFS, it's a basic file processor for terrain generation based on greyscale images, just that and nothing else.
Just for fun I've d/led your avatar, saved it as a PPM ASCII (RTFM) with XnView, ran the plugin. A "terrain" of around 26000 faces has been drawn in a matter of a minute. I must say that you are much prettier in real life than in SU
Regards, -
@didier bur said:
...It's strange to see that users who complain about uselessness of scripts or say they don't work never read the dox...
Didier, you are right - as I said above, I tried it only once but than gave up. and true that did not pay too much attention to the dox - but did not even complain!
-
Didier, I did not complain, I did not call it useless and indeed I did not read any docs. I did try to find docs on the above mentioned link. I do know that lots of height maps are either in gray scale or showing heights as colors that can easily be converted to grayscale. For such height maps a script like yours is VERY useful, as long as the dummie first time user can find the docs. I found out today that I should have clicked the asterix. That's what the Dutch call "looking no further than a nose length".
Maybe it would be a good idea to use more standard icons, like the Acrobat icon, to show dummies that we should download a document.
OTOH even after reading the beautiful pdf, I still don't know what went wrong with my first test of heightfield_gen.rb. I used the face of my first message in this thread, scaled down a lot and saved as PPM in Paintshop Pro. The ruby gave no error message. I did allow it to finish for about 30 minutes.
I'm currently on another computer, I'll give it another honest try when I'm back home.But you have to admit that my avatar would look prettier in well performed SFS than what you've done to my face.
[Maggy]
-
@unknownuser said:
Lewis....dumb question but, does it follow that if I took a snapshot on Google Earth I could use GIMP and it's sfs plug-in to creat contours in my model?
I don't think that would work...GE imagery is "orthorectified" (see this Wikipedia description http://en.wikipedia.org/wiki/Orthophoto )so that the tiles tessellate across the terrain without obnoxious joints. To use SFS, you need to start with a photograph where you know everything about the camera and where it was versus the target, and everything about the altitude and azimuth of the source of the light that illuminated the target when the photograph was taken. The orthorectifying process presumably makes a mess of those constants.
But if you had a non-rectified satellite or aerial photo and you had the required sun and camera information, you could convert the photo to a grayscale heightmap and use Didier's Ruby to make a mesh of it. It's my understanding that sfs is always more of an art than a science, so you generally have to make assumptions and tweak the settings once you have a result that seems "in the ballpark."
I'll try to find the time tonight or tomorrow to get this running and see if I can make it work on some test subject.
--Lewis
[Lewis Wadsworth]
-
Just to amend a previous comment, it seems that this SFS plugin will not install on GIMP on anything but Windows, despite a source code package being available. (GIMP is interesting in that on UNIX-type systems it has its own built-in compiler for plug-ins.) I'll give it a shot on my Windows computer tomorrow night...I've already used up my spare time for the evening trying to interpret the errors flagged when trying to install it on my Linux machine (where I had hoped to use the resultant heightmaps with Blender).
Incidentally, while doing a web-search on this SFS plugin I found a company that claims to make something similar for Photoshop.
http://www.cgsd.com/bumptexture/SFS.html
They want nearly $500 for a package of filters (for Windows only) that includes this. There's a 10-day trial period, though. The website looks a bit amateurish, and their movie of the filter in action seems to show an archaic version of Photoshop... PS 5 or 6, so who knows if this is still a viable plugin.
--Lewis
[Lewis Wadsworth]
-
They call it SFS but it's actually bumpmapping.
See http://docs.gimp.org/en/plug-in-bump-map.html
As you can see, the middle part of the example picture strip is the actual bump map, white is high, black is low. Just like what Didiers ruby expects.Both SFS and bumpmapping are science at its peek. Bumpmaps from actual 3d information are a very reliable way of representing this 3d info textured in a 2.5D way in very small file format. Going from a single 2D picture to 3D can not be reliably done with bumpmapping, while SFS can, but not with any image.
There are high end video camera's with very advanced bumpmapping capabilities, but they use time of flight (TOF) technology to create the bumpmap. TOF means it uses the time that light needs to reach the sensor to calculate the distance. You can see the result of such cameras being used very creatively for example in movies and commercials where they're able to freeze frame while you see smoke and flowing water "freeze" in mid air, then zoom, pan, orbit the view. What you do not see is that the camera actually doesn't move or zoom.
Another effect is titles floating in mid air between a show host and the background in a live broadcast.[Maggy]
-
@maggy said:
They call it SFS but it's actually bumpmapping.
See http://docs.gimp.org/en/plug-in-bump-map.htmlDifferent plugin, Maggy. That is a GIMP mimic of a Photoshop plugin, Lighting Effects, that I have been using since 1993 or so.
A bump map is one use of the grayscale images you produce with the results of sfs, otherwise known as photoclinometry ( http://en.wikipedia.org/wiki/Photoclinometry ). In most 3D modelers, a bump map is procedural distortion of texture based on a grayscale image, but a heightmap is used to create or displace mesh polygons. The images below are of a SketchUp model I made of the Noctis Labyrinthus feature on Mars, constructed with a heightmap produced using MOLA data, courtesy of NASA/JPL. It is not a product of SFS, but if you download and decompress the SFS plugin for GIMP it does include a Viking satellite image of another feature on Mars that you can convert to a heightmap. I'll be trying it tonight, assuming I have access to a PC running Windows.
There is seriously complex application package available from NASA, called ISIS 2, that incudes pc2d, a shape-from-shadow interpreter used by exo-geographers for analyzing planetary images. It actually includes procedures for compensating for albedo, so that you don't have to cover whole planets in talcum powder.
--Lewis
[Lewis Wadsworth]
-
Your link to the Paintshop pluging contained no explanation whatsoever of the word bump map. That is why I placed another url, to a Gimp plugin that does explain that term.
But the Paintshop plugin is a smart bumpmapper and not a real SFS.
@unknownuser said:
Animation of space ship going through a tunnel (seen at right) lined with rocks. Bump maps of the rock material were created by the Shape from Shading plug-in.
@unknownuser said:
Image can be rendered as a bump map in your 3d application
First quote can be read under Tunnel.avi, second is the end of the plug-in demo SFS.avi.
edit: added model to demonstrate difference between BM and SFS. This guy is nice and grey. I have neither BM nor SFS software installed. But I believe BM will probably push this man into the background while SFS at least theoretically should be able to see that he is floating in mid air. We can see that at first glance. It was the intention of mister (professor? doctor?) Horn, on of the founding fathers of SFS to give computer vision that very same level of intelligence.
The S from Shape stands for 3D, bump maps can give a very nice 3D impression, but are actually no more 3D than stereoscopy.http://www.sketchucation.com/forums/scf/sas/Ruby/BMP%20vs%20SFS.skp
Advertisement