Exemple #1
0
 public BitmapByteSeq(IBitmap copy) : this(copy.Size)
 {
     foreach (var p in copy.TruePositions())
     {
         this[p] = true;
     }
 }
Exemple #2
0
 public static int Count(this IBitmap bitmap)
 {
     if (bitmap is Bitmap b)
     {
         return(b.Count);
     }
     return(bitmap.TruePositions().Count());
 }
Exemple #3
0
        public static Map <T> ToMap <T>(this IBitmap bitmap, T on, T off)
        {
            var map = new Map <T>(bitmap.Size);

            map.Fill(off);
            foreach (var g in bitmap.TruePositions())
            {
                map[g] = on;
            }
            return(map);
        }
Exemple #4
0
        public static Map <int> ToIntMap(this IBitmap bitmap, int on = 1, int off = 0)
        {
            var map = new Map <int>(bitmap.Size);

            map.Fill(off);
            foreach (var g in bitmap.TruePositions())
            {
                map[g] = on;
            }
            return(map);
        }
Exemple #5
0
        public static Map <char> ToCharMap(this IBitmap bitmap, char on = 'X', char off = '.')
        {
            var map = new Map <char>(bitmap.Size);

            map.Fill(off);
            foreach (var g in bitmap.TruePositions())
            {
                map[g] = on;
            }
            return(map);
        }
Exemple #6
0
 /// <summary>
 ///     Does any cell intersect/overlap between lhs and rhs?
 /// </summary>
 public static bool Intersects(this IBitmap lhs, IBitmap rhs)
 {
     foreach (var t in lhs.TruePositions())
     {
         if (rhs[t])
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #7
0
        public static IBitmap Subtract(this IBitmap lhs, IBitmap rhs)
        {
            if (lhs.Size != rhs.Size)
            {
                throw new InvalidDataException();
            }

            var res = new Bitmap(lhs);

            foreach (var on in rhs.TruePositions())
            {
                res[on] = false;
            }

            return(res);
        }
            public Master(IBitmap reference)
            {
                Reference = reference;

                var m = new int[reference.Width * reference.Height];

                m.Fill(-1);

                var l  = new List <VectorInt2>();
                var cc = 0;

                foreach (var position in reference.TruePositions())
                {
                    l.Add(position);
                    m[reference.ToLinearSpace(position)] = cc++;
                }
                MapOut = l.ToImmutableList();
                MapIn  = m.ToImmutableArray();
            }