예제 #1
0
 public ImageWithName(ImageWithName original)
 {
     image  = original.image;
     name   = original.name;
     height = original.height;
     width  = original.width;
 }
예제 #2
0
        public static ImageWithName[] LoadImages(string imageSourcePath, string[] imgNameList)
        {
            var SourceImageList = new ImageWithName[imgNameList.Length];

            Parallel.For(0, imgNameList.Length, (i) =>
            {
                Bitmap img         = new Bitmap(imageSourcePath + imgNameList[i]);
                SourceImageList[i] = new ImageWithName(img, imgNameList[i]);
            });
            return(SourceImageList);
        }
 public static ImageWithName InvertImage(ImageWithName img)
 {
     Parallel.For(0, img.height, (y) =>
     {
         Parallel.For(0, img.width, (x) =>
         {
             img.image[x, y] = ImageProcessor.InvertPixel(img.image[x, y]);
         });
     });
     return(img);
 }
        public static ImageWithName InvertImage(ImageWithName img)
        {
            Gpu gpu = Gpu.Default;

            gpu.For(0, img.height, (y) =>
            {
                gpu.For(0, img.width, (x) =>
                {
                    img.image[x, y] = ImageProcessor.InvertPixel(img.image[x, y]);
                });
            });
            return(img);
        }
        public static ImageWithName InvertImage(ImageWithName img)
        {
            Console.WriteLine("ooo");
            using (MemoryBuffer<SimplePixel> buffer = gpu.Allocate<SimplePixel>(img.image.Length))
            {
                buffer.CopyFrom(img.Get1DArr(), 0, Index1.Zero, img.image.Length);

                kernel(img.image.Length, buffer.View);

                // Wait for the kernel to finish...
                gpu.Synchronize();

                return new ImageWithName(buffer.GetAsArray(), img.width, img.height, img.name); ; 
            }
        }
예제 #6
0
        public static void RunILGPU(string[] imgNameList)
        {
            Console.WriteLine("Loading");
            ImageWithName[] SourceImageList = LoadImages(imageSourcePath, imgNameList);
            ImageWithName[] OutImageList    = new ImageWithName[imgNameList.Length];

            //imageProcessingData = new string[SourceImageList.Length];

            Console.WriteLine("Processing");
            for (int i = 0; i < SourceImageList.Length; i++)
            {
                OutImageList[i] = ILGPUInverter.InvertImage(new ImageWithName());
            }
            Console.WriteLine("Saving");
            SaveImages(imageOutPath, OutImageList);
        }