コード例 #1
0
        private void DoTest(int numOps, bool doGS)
        {
            Processor p = new Processor();
            p.Image = _img;

            DisplayMessage("Starting managed average method"+Environment.NewLine);

            Stopwatch s = Stopwatch.StartNew();
            for (int i = 0; i < numOps; ++i)
                p.ThresholdMA(125);
            s.Stop();

            DisplayMessage("Managed average method took "+s.ElapsedMilliseconds.ToString()+" milliseconds, for an average of "+(s.ElapsedMilliseconds/(float)numOps)+" per threshold."+Environment.NewLine);

            s.Reset();

            DisplayMessage("Starting unsafe average method" + Environment.NewLine);
            s.Start();
            for (int i = 0; i < numOps; ++i)
                p.ThresholdUA(125);
            s.Stop();
            DisplayMessage("Unsafe average method took " + s.ElapsedMilliseconds + " milliseconds, for an average of " + (s.ElapsedMilliseconds / (float)numOps) + " per threshold." + Environment.NewLine);

            s.Reset();

            if (doGS)
            {
                DisplayMessage("Starting GetPixel\\SetPixel average method" + Environment.NewLine);
                s.Start();
                for (int i = 0; i < numOps; ++i)
                    p.ThresholdGS(125);
                s.Stop();
                DisplayMessage("GetPixel\\SetPixel average method took " + s.ElapsedMilliseconds + " milliseconds, for an average of " + (s.ElapsedMilliseconds / (float)numOps) + " per threshold." + Environment.NewLine);
            }
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: pebblecode/raci
        public void TestProcessor()
        {
            var testImage = Image.FromFile(@"C:\dev\Code\raci\Tests\testbmp.bmp") as Bitmap;
            var libraryDirectory = @"C:\dev\Code\raci\Tests\LibraryImages\";

            var libraryImages = Directory.GetFiles(libraryDirectory).Select(file => Image.FromFile(file) as Bitmap).ToList();

            var processor = new Processor();

            var output = processor.ProcessImage(testImage, libraryImages, 5, 5);

            output.Save(@"C:\dev\Code\raci\Tests\output.bmp", ImageFormat.Bmp);
        }
コード例 #3
0
ファイル: ImageController.cs プロジェクト: pebblecode/raci
 public HttpResponseMessage Get(string tags)
 {
     var flickrService = new FlickrImageService();
     var images = flickrService.GetImages(tags).Take(2).ToArray();
     var processor = new Processor();
     var resultImage = processor.ProcessImage(images.First().Image, images.Skip(1).Select(i=>i.Image), 20, 20);
     HttpResponseMessage result;
     using (var ms = new MemoryStream())
     {
         var bitmap = new Bitmap(resultImage);
         bitmap.Save(ms, ImageFormat.Jpeg);
         result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(ms.ToArray()) };
     }
     result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
     return result;
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: pebblecode/raci
        public ActionResult Index(string tags, string original, string block, int blockSize = 20)
        {
            var processor = new Processor();
            Bitmap resultImage;

            if (string.IsNullOrWhiteSpace(original) || string.IsNullOrWhiteSpace(block))
            {
                tags = tags ?? "cheese,stuff";
                var flickrService = new FlickrImageService();
                var images = flickrService.GetImages(tags).Take(2).ToArray();

                resultImage = processor.ProcessImage(
                    images.First().Image, images.Skip(1).Select(i => i.Image), blockSize, blockSize);
                HttpResponseMessage result;
                using (var ms = new MemoryStream())
                {
                    var bitmap = new Bitmap(resultImage);
                    bitmap.Save(ms, ImageFormat.Jpeg);
                    return
                        View(
                            new FlickModel(
                                images.First().Encoded,
                                images.Skip(1).First().Encoded,
                                Convert.ToBase64String(ms.ToArray())));
                }
            }
            var originalImage = this.Load(original);
            var blockImage = this.Load(block);
            resultImage = processor.ProcessImage(originalImage.Image, new[] { blockImage.Image, }, blockSize, blockSize);

            using (var ms = new MemoryStream())
            {
                var bitmap = new Bitmap(resultImage);
                bitmap.Save(ms, ImageFormat.Jpeg);
                return View(new FlickModel(originalImage.Encoded, blockImage.Encoded, Convert.ToBase64String(ms.ToArray())));
            }
        }
コード例 #5
0
 public Shock()
 {
     InitializeComponent();
     p = new Processor();
 }