Monday, April 07, 2008 7:20 AM
My notes for Extending Powershell to do Image Processing, Part II
Ok, here's how you create a CmdLet that uses DotImage:
1 Download the attached zip open the solution
2. Build it -- my dll is named AtalasoftSnapin.dll
Here is the code for GetImage.cs, the implementation of the get-image cmdlet
// the name of the cmdlet is get-image
public class GetImageCommand : Cmdlet
private string _filename;
// it has one parameter and it is mandatory
// and can be piped in
public string Filename
_filename = value;
protected override void BeginProcessing()
// take the string they pass, treat it as
// a filename, and load it into an image
protected override void ProcessRecord()
protected override void EndProcessing()
3. Install it with these lines in Powershell
4. Now in Powershell, you can type
> get-image "full path to image"
> dir *.jpg | get-image
After adding in the cmdlets for gray-image and combinechannels-image, you can now create the red-blue 3D images I showed.
1. Take two pictures, one with your left eye, and one with your right
2. Make them both gray:
> get-image "path to image" | gray-image | save-image "output image"
3. And now put the left image in the red channel, and the right image in the blue and green.
> combinechannels-image -r (get-image "left image") -g (get-image "right image") -b (get-image "right image") | save-image "3d image"
replace "left image" and "right image" with the names of your gray images. replace "3d image" with the name of your output image
You might think that the whole point of the presentation was to get this picture (click for larger version):
But, it's not -- the point of the presentation is to get this picture:
A solution with my code is attached below.