Esempio n. 1
0
        public IEnumerable <Bitmap> GetMidResConvolutionReducedAsBitmap(PhysicalImage physicalImage) // Only for demo
        {
            var convolutionResults = GetMidResConvolution2(physicalImage);

            return(convolutionResults
                   .Select(Reduce)
                   .Select(r => r.ToBitmap()));
        }
Esempio n. 2
0
        private FlatArray2DArray <int>[] GetMidResConvolution2(PhysicalImage physicalImage)
        {
            int GetConvolution(IEnumerable <int> convolutionPixels, double[] filter)
            {
                int value = (int)convolutionPixels
                            .Zip(filter, (a, b) => a * b)
                            .Sum();

                value = value < 0 ? 0 : value;
                value = value > 255 ? 255 : value;

                return(value);
            }

            FastBitmap.FastBitmap bitmap = _loader.LoadImage(physicalImage.ImagePath);
            var bitmapAsIntensity        = new FastBitmapToIntensity2DArrayAdapter(bitmap);

            var convolution135Result =
                new FlatArray2DArray <int>(new int[bitmap.Width * bitmap.Height], bitmap.Width, bitmap.Height);
            var convolution45Result =
                new FlatArray2DArray <int>(new int[bitmap.Width * bitmap.Height], bitmap.Width, bitmap.Height);
            var convolutionHorizontalResult =
                new FlatArray2DArray <int>(new int[bitmap.Width * bitmap.Height], bitmap.Width, bitmap.Height);
            var convolutionVerticalResult =
                new FlatArray2DArray <int>(new int[bitmap.Width * bitmap.Height], bitmap.Width, bitmap.Height);
            var convolutionEdgeResult =
                new FlatArray2DArray <int>(new int[bitmap.Width * bitmap.Height], bitmap.Width, bitmap.Height);

            bitmap.Lock();
            for (int y = 0; y < bitmap.Height; y++)
            {
                for (int x = 0; x < bitmap.Width; x++)
                {
                    var convolutionPixels =
                        GetConvolutionPixels(bitmapAsIntensity, new Rectangle(x - 1, y - 1, 3, 3)).ToArray();

                    convolution135Result[x, y]        = GetConvolution(convolutionPixels, StatsGenerator.MidRes135Filter);
                    convolution45Result[x, y]         = GetConvolution(convolutionPixels, StatsGenerator.MidRes45Filter);
                    convolutionHorizontalResult[x, y] =
                        GetConvolution(convolutionPixels, StatsGenerator.MidResHorizontalFilter);
                    convolutionVerticalResult[x, y] = GetConvolution(convolutionPixels, StatsGenerator.MidResVerticalFilter);
                    convolutionEdgeResult[x, y]     = GetConvolution(convolutionPixels, StatsGenerator.MidResEdgeFilter);
                }
            }

            bitmap.Unlock();

            var convolutionResults = new[]
            {
                convolution135Result,
                convolution45Result,
                convolutionHorizontalResult,
                convolutionVerticalResult,
                convolutionEdgeResult,
            };

            return(convolutionResults);
        }
Esempio n. 3
0
        private ImageAndStats GetMatchableSegments(PhysicalImage physicalImage)
        {
            var img = _loader.LoadImage(physicalImage.ImagePath);
            // For movie stills with widescreen bars above/below, start further down and end higher up
            IEnumerable <Rectangle> rects = GetSegmentRectangles(new Rectangle(6, 6, img.Width - 12, img.Height - 12));
            // IEnumerable<Rectangle> rects = GetSegmentRectangles(new Rectangle(0, 0, img.Width, img.Height));
            var segmentStats = new List <SegmentAndStats>();

            foreach (var rectangle in rects)
            {
                var imageManipulationInfo   = new ImageManipulationInfo(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                Stats.BasicStats basicStats = GetStats(physicalImage,
                                                       imageManipulationInfo);
                segmentStats.Add(new SegmentAndStats(imageManipulationInfo, basicStats));
            }

            return(new ImageAndStats(physicalImage, segmentStats));
        }
Esempio n. 4
0
        public IEnumerable <Bitmap> GetRefinedMatches2(PhysicalImage image, ImageManipulationInfo manipulationInfo)
        {
            var bitmap = _loader.LoadImage(image.ImagePath);

            return(GetRefinedMatches2(bitmap, manipulationInfo));
        }
Esempio n. 5
0
 public Bitmap GetBitmap(PhysicalImage physicalImage, ImageManipulationInfo manipulationInfo)
 {
     return(BitmapAdapter.FromPath(physicalImage.ImagePath, _loader)
            .GetSegment(manipulationInfo));
 }
Esempio n. 6
0
 public BasicStats GetStats(PhysicalImage image, ImageManipulationInfo manipulationInfo)
 {
     global::FastBitmap.FastBitmap bitmap = _loader.LoadImage(image.ImagePath);
     return(GetStats(bitmap, manipulationInfo));
 }