[Talk-cz] Tracer - nastavení

Jan Bilak jan.bilak.osm na gmail.com
Pondělí Březen 1 12:32:21 UTC 2010


Zdroják SmallHoleRemover filtru vypadá takto:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Osm.Kn.Trace.Server.Trace.Interfaces;

namespace SmallHoleRemover
{
    [BitmapFilter("SmallHoleRemover")]
    public class SmallHoleRemover : IBitmapFilter
    {
        const byte BACKGROUND = 0;
        const byte PEN = 1;
        const byte TEMP = 2;

        #region IBitmapFilter Members

        public byte[][] Filter(byte[][] bitmap)
        {
            int h = bitmap.Length;
            int w = bitmap[0].Length;

            for (int y = 1; y < h - 1; y++)
            {
                for (int x = 1; x < w - 1; x++)
                {
                    if ((bitmap[y][x] == PEN) &&
                        (bitmap[y][x - 1] != BACKGROUND || bitmap[y][x
+ 1] != BACKGROUND ||
                        bitmap[y - 1][x] != BACKGROUND || bitmap[y +
1][x] != BACKGROUND))
                        bitmap[y][x] = TEMP;
                }
            }
            for (int y = 1; y < h - 1; y++)
            {
                for (int x = 1; x < w - 1; x++)
                {
                    if (bitmap[y][x] == TEMP)
                        bitmap[y][x] = PEN;
                }
            }

            return bitmap;
        }

        #endregion

        #region IConfigurable Members

        public void Init(IDictionary<string, string> confValues)
        {
        }

        #endregion
    }
}




Další informace o konferenci talk-cz