(string[] args)
| 23 | class HelloWorld { |
| 24 | |
| 25 | static void Main(string[] args) { |
| 26 | |
| 27 | try { |
| 28 | |
| 29 | // Create an image |
| 30 | PixelIDValueEnum pixelType = PixelIDValueEnum.sitkUInt8; |
| 31 | VectorUInt32 imageSize = new VectorUInt32( new uint[] { 128, 128 } ); |
| 32 | Image image = new Image( imageSize, pixelType ); |
| 33 | |
| 34 | // Create a face image |
| 35 | VectorDouble faceSize = new VectorDouble( new double[] { 64, 64 } ); |
| 36 | VectorDouble faceCenter = new VectorDouble( new double[] { 64, 64 } ); |
| 37 | Image face = SimpleITK.GaussianSource( pixelType, imageSize, faceSize, faceCenter ); |
| 38 | |
| 39 | // Create eye images |
| 40 | VectorDouble eyeSize = new VectorDouble( new double[] { 5, 5 } ); |
| 41 | VectorDouble eye1Center = new VectorDouble( new double[] { 48, 48 } ); |
| 42 | VectorDouble eye2Center = new VectorDouble( new double[] { 80, 48 } ); |
| 43 | Image eye1 = SimpleITK.GaussianSource( pixelType, imageSize, eyeSize, eye1Center, 150 ); |
| 44 | Image eye2 = SimpleITK.GaussianSource( pixelType, imageSize, eyeSize, eye2Center, 150 ); |
| 45 | |
| 46 | // Apply the eyes to the face |
| 47 | face = SimpleITK.Subtract( face, eye1 ); |
| 48 | face = SimpleITK.Subtract( face, eye2 ); |
| 49 | face = SimpleITK.BinaryThreshold( face, 200, 255, 255 ); |
| 50 | |
| 51 | |
| 52 | // Create the mouth |
| 53 | VectorDouble mouthRadii = new VectorDouble( new double[] { 30, 20 } ); |
| 54 | VectorDouble mouthCenter = new VectorDouble( new double[] { 64, 76 } ); |
| 55 | Image mouth = SimpleITK.GaussianSource( pixelType, imageSize, mouthRadii, mouthCenter ); |
| 56 | mouth = SimpleITK.BinaryThreshold( mouth, 200, 255, 255 ); |
| 57 | mouth = SimpleITK.Subtract( 255, mouth ); |
| 58 | |
| 59 | // Paste the mouth onto the face |
| 60 | VectorUInt32 mouthSize = new VectorUInt32( new uint[] { 64, 18 } ); |
| 61 | VectorInt32 mouthLoc = new VectorInt32( new int[] { 32, 76 } ); |
| 62 | face = SimpleITK.Paste( face, mouth, mouthSize, mouthLoc, mouthLoc ); |
| 63 | |
| 64 | // Apply the face to the original image |
| 65 | image = SimpleITK.Add( image, face ); |
| 66 | |
| 67 | // Display the results |
| 68 | if (Environment.GetEnvironmentVariable("SITK_NOSHOW") == null) |
| 69 | SimpleITK.Show( image, "Hello World: CSharp", true ); |
| 70 | |
| 71 | } catch (Exception ex) { |
| 72 | Console.WriteLine(ex); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | } |
| 77 | } |
nothing calls this directly
no outgoing calls
no test coverage detected