示例#1
0
 public void GlobalSetup()
 {
     _drawingBitmap = DrawingBitmapExtension.FromFile(_sourceBitmapPath);
     _bitmapSource  = BitmapSourceExtension.FromFile(_sourceBitmapPath);
     _container     = _drawingBitmap.ToImagePixelsContainer();
     _imageSharp    = ImageSharpBgr24Extension.FromFile(_sourceBitmapPath);
 }
示例#2
0
        private void LoadImageFlow1(string path)
        {
            var bitmapSource0 = BitmapSourceExtension.FromFile(path);

            using var drawingBitmap1 = bitmapSource0.ToDrawingBitmap();
            using var container1     = drawingBitmap1.ToImagePixelsContainer();
            var pixels1 = container1.Pixels;

            using var image1 = pixels1.ToImageSharpBgr24();

            var bitmapSource2 = image1.ToBitmapSource();

            using var image2     = bitmapSource2.ToImageSharpBgr24();
            using var container2 = image2.ToImagePixelsContainer();
            var pixels2 = container2.Pixels;

            using var drawingBitmap2 = pixels2.ToDrawingBitmap();

            using var image3         = drawingBitmap2.ToImageSharpBgr24();
            using var drawingBitmap3 = image3.ToDrawingBitmap();
            var bitmapSource3 = drawingBitmap2.ToBitmapSource();

            using var container3 = bitmapSource3.ToImagePixelsContainer();
            var pixels3       = container3.Pixels;
            var bitmapSource4 = pixels3.ToBitmapSource();

            ImageSource1.Value = bitmapSource4;
        }
        public void ToEachClasses()
        {
            // bmp から作成した BitmapSource を各クラスに変換して、画素平均値を比較する
            var bitmapSource = BitmapSourceExtension.FromFile(_sourceBitmapPath);
            var avesBase     = bitmapSource.GetChannelsAverage().ToList();

            avesBase.Count.Is(4);

            // ToDrawingBitmap
            using var bitmap0 = bitmapSource.ToDrawingBitmap();
            var aves00 = bitmap0.GetChannelsAverage().ToList();

            aves00.Count.Is(4);
            aves00.Is(avesBase);

            // ToWriteableBitmap(BitmapSource)
            var writeable = bitmapSource.ToWriteableBitmap();
            var aves10    = writeable.GetChannelsAverage().ToList();

            aves10.Count.Is(4);
            aves10.Is(avesBase);

            bitmapSource.CopyToWriteableBitmap(writeable);
            var aves11 = writeable.GetChannelsAverage().ToList();

            aves11.Count.Is(4);
            aves11.Is(avesBase);

            // ToImagePixelsContainer
            using var container = bitmapSource.ToImagePixelsContainer();
            var pixels = container.Pixels;
            var aves20 = pixels.GetChannelsAverage().ToList();

            aves20.Count.Is(3);
            aves20.Is(avesBase.Take(3));     // 3chに揃える

            bitmapSource.CopyToImagePixels(ref pixels);
            var aves21 = pixels.GetChannelsAverage().ToList();

            aves21.Count.Is(3);
            aves21.Is(avesBase.Take(3));     // 3chに揃える

            // ToImageSharpBgr24
            using var image = bitmapSource.ToImageSharpBgr24();
            var aves30 = image.GetChannelsAverage().ToList();

            aves30.Count.Is(3);
            aves30.Is(avesBase.Take(3));     // 3chに揃える
        }
        public void FileLoadSave(string imagePath, string extension)
        {
            // 画像ファイルを Load -> Save -> Load して画素平均値を比較する
            var bitmap0  = BitmapSourceExtension.FromFile(imagePath);
            var baseAves = bitmap0.GetChannelsAverage().ToList();

            var savePath = GetTempFileName() + extension;

            bitmap0.ToImageFile(savePath);

            var bitmap1 = BitmapSourceExtension.FromFile(savePath);
            var newAves = bitmap1.GetChannelsAverage().ToList();

            newAves.Is(baseAves);

            System.IO.File.Delete(savePath);
        }
示例#5
0
        public MainWindowViewModel()
        {
            var bitmapImage = BitmapSourceExtension.FromFile(@"Asserts\image1.bmp");

            SourceImage = new ReactivePropertySlim <BitmapSource>(initialValue: bitmapImage);

            using var pixelContainer = bitmapImage.ToPixelMatrixContainer();
            var fullPixelMatrix = pixelContainer.FullPixels;

            // 元画像の画素値平均
            var channelAverage1 = fullPixelMatrix.GetChannelsAverageOfEntire();

            Debug.WriteLine($"{channelAverage1:f1}");

            // 1. 三角領域を指定色で指定塗り
            FillTriangle(fullPixelMatrix);

            // 2. 四角形(塗りつぶしなし)を描画
            fullPixelMatrix.DrawRectangle(Colors.Cyan.ToPixel3ch(), 200, 200, 100, 200);

            // 3. 上部を切り出して指定塗り
            var headerPixelMatrix = fullPixelMatrix.CutOutPixelMatrix(0, 0, fullPixelMatrix.Width, 30);

            headerPixelMatrix.FillAllPixels(Pixel3ch.Gray);
            var headerChannelAverage2 = headerPixelMatrix.GetChannelsAverageOfEntire();

            // 4. 上部を除いた左部を切り出してグレスケ塗り
            var leftPixelMatrix = fullPixelMatrix.CutOutPixelMatrix(0, headerPixelMatrix.Height, 50, fullPixelMatrix.Height - headerPixelMatrix.Height);

            FillGrayScaleVertical(leftPixelMatrix);

            // BitmapSourceに変換してView表示
            var writableBitmap = fullPixelMatrix.ToWriteableBitmap();

            WriteableImage = new ReactivePropertySlim <WriteableBitmap>(initialValue: writableBitmap);
        }
 public void BitmapSource_FromTiff()
 {
     var bitmap = BitmapSourceExtension.FromFile(_tifPath);
 }
 public void BitmapSource_FromPng()
 {
     var bitmap = BitmapSourceExtension.FromFile(_pngPath);
 }
 public void BitmapSource_FromBitmap()
 {
     var bitmap = BitmapSourceExtension.FromFile(_bmpPath);
 }
 public void BitmapSource_FromJpeg()
 {
     var bitmap = BitmapSourceExtension.FromFile(_jpgPath);
 }
 public void GlobalSetup()
 {
     _bitmapSource    = BitmapSourceExtension.FromFile(_sourceBitmapPath);
     _writeableBitmap = _bitmapSource.ToWriteableBitmap();
     _container       = new ImagePixelsContainer(_bitmapSource.PixelWidth, _bitmapSource.PixelHeight);
 }
 public void GlobalSetup()
 {
     _drawingBitmap = DrawingBitmapExtension.FromFile(_sourceBitmapPath);
     _bitmapSource  = BitmapSourceExtension.FromFile(_sourceBitmapPath);
 }
示例#12
0
 private void LoadImageFlow0(string path)
 {
     ImageSource0.Value = BitmapSourceExtension.FromFile(path);
 }