Wednesday, May 10, 2006 5:52 PM
by
loufranco
Atalasoft in 3D
Part of what I'm doing puts me knee-deep in Atalasoft
ImageCommands. I was staring at some results of TintGrayscale and
wondered how easy it would be to make the kind of 3D images that are a
combined red and blue images with Atalasoft dotImage. Turns out, it's
really easy.
Here is what you need to do:
1. Take two pictures of a subject with the camera shifted three inches horizontally.
2. Turn both images to grayscale
AtalaImage left = new AtalaImage(_leftName);
left = left.GetChangedPixelFormat(PixelFormat.Pixel8bppGrayscale);
AtalaImage right = new AtalaImage(_rightName);
right = right.GetChangedPixelFormat(PixelFormat.Pixel8bppGrayscale);
3.
Make a third image that uses AtalaImage.CombineChannels where the left
image is in channels one and two, and the right image is in channel
three.
_combinedChannelsImg = AtalaImage.CombineChannels(
PixelFormat.Pixel24bppBgr, new AtalaImage[] { left, left, right });
4. Use ShiftChannelsCommand to correct for any offset errors that may have been introduced when the pictures were taken.
ShiftChannelsCommand lscc = new ShiftChannelsCommand(-hstep, -vstep,
ChannelFlags.Channel3, 127);
ShiftChannelsCommand rscc = new ShiftChannelsCommand(hstep, vstep,
ChannelFlags.Channel1 | ChannelFlags.Channel2,
127);
_combinedChannelsAndShiftedImg =
lscc.ApplyToImage(_combinedChannelsImg);
_combinedChannelsAndShiftedImg =
rscc.ApplyToImage(_combinedChannelsAndShiftedImg);
If you want to run an application built on this code, download the zip attached at the bottom of this post. I've included
a left and right image of our lounge in the zip to play with (Now supports .NET 1.1).
- Click in the top left box and pick your left image
- Click the top right box and pick your right image.
- Click the Combine button.
- Use the sliders if adjust the position of the channels if your
originals aren't aligned well (shouldn't be necessary for the lounge
pictures).
- Click on the combined image to save it.
You need 3D glasses to see the effect (right eye red, left eye blue).
Update: The resulting image