Exemple #1
0
    static void Main(string[] args)
    {
        try
        {
            // Read an explicitly typed image
            itkImageBase input = itkImage_UC2.New();
            input.Read(args[0]);

            // Allocate an empty output image
            itkImageBase output = itkImage_UC2.New();
            itkImageRegion region = input.LargestPossibleRegion;
            output.SetRegions(region);
            output.Allocate();
            output.FillBuffer(0);
            output.Spacing = input.Spacing;
            output.Origin = input.Origin;

            // Create iterators to walk the input and output images
            itkImageRegionConstIterator_IUC2 inputIt;
            itkImageRegionIterator_IUC2 outputIt;
            inputIt = new itkImageRegionConstIterator_IUC2(input, region);
            outputIt = new itkImageRegionIterator_IUC2(output, region);

            // Walk the images using the iterators
            foreach (itkPixel pixel in inputIt)
            {
                outputIt.Set(pixel);
                outputIt++;
            }

            // Write the output image
            output.Write(args[1]);

            // Dispose of the images
            input.Dispose();
            output.Dispose();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    } // end main
Exemple #2
0
        private unsafe static void CopyToUnsigned8(ImageGraphic image, itkImageBase itkImage)
        {
            fixed(byte *pSrcByte = image.PixelData.Raw)
            {
                itkImageRegionIterator_IUC2 inputIt = new itkImageRegionIterator_IUC2(itkImage, itkImage.LargestPossibleRegion);
                byte *pSrc   = (byte *)pSrcByte;
                int   height = image.Rows;
                int   width  = image.Columns;
                byte  pixelValue;

                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        pixelValue = pSrc[0];
                        inputIt.Set(pixelValue);
                        pSrc++;
                        inputIt++;
                    }
                }
            }
        }
Exemple #3
0
 private unsafe static void CopyToUnsigned8(ImageGraphic image, itkImageBase itkImage)
 {
     fixed (byte* pSrcByte = image.PixelData.Raw)
     {
         itkImageRegionIterator_IUC2 inputIt = new itkImageRegionIterator_IUC2(itkImage, itkImage.LargestPossibleRegion);
         byte* pSrc = (byte*)pSrcByte;
         int height = image.Rows;
         int width = image.Columns;
         byte pixelValue;
         for (int y = 0; y < height; y++)
         {
             for (int x = 0; x < width; x++)
             {
                 pixelValue = pSrc[0];
                 inputIt.Set(pixelValue);
                 pSrc++;
                 inputIt++;
             }
         }
     }
 }