Exemple #1
0
 public ThresholdScanner(IScanData scanData, ILookupTable lookupTable, Func<ILabelMap> labelMap, ICrossChecker crossCheck)
 {
     _scanData = scanData;
     _labelMap = labelMap;
     _lookupTable = lookupTable;
     _crossCheck = crossCheck;
 }
Exemple #2
0
 public Link(ILookupTable lookupTable, ILinkCache linkCache, IRandomCharGenerator randomCharGenerator)
 {
     _lookupTable         = lookupTable;
     _linkCache           = linkCache;
     _randomCharGenerator = randomCharGenerator;
     random = new Random();
 }
Exemple #3
0
        public ProjectionView(Axis axis, IScanData scanData, ILookupTable lookupTable, LabelMapSet labelMapSet, IProbe probe)
        {
            _axis        = axis;
            _scanData    = scanData;
            _lookupTable = lookupTable;
            _labelMapSet = labelMapSet;
            _probe       = probe;

            _lookupTable.MapChanged       += () => this.Invoke(new MethodInvoker(Rebuild));
            _scanData.DataUpdated         += () => this.Invoke(new MethodInvoker(ScanDataOnDataUpdated));
            _labelMapSet.LabelMapUpdated  += LabelMapOnLabelDataChanged;
            _labelMapSet.LabelMapDeleted  += LabelMapOnLabelDataChanged;
            _labelMapSet.LabelMapSetReset += () => surface.Invalidate();
            _labelMapSet.LabelMapCurrentSelectionChanged += () =>
            {
                _labelMapSet.Current.Crop.CropChanged += () => surface.Invalidate();
                surface.Invalidate();
            };

            InitializeComponent();
        }
Exemple #4
0
        public static Probe GetStartingProbe(Point3D point, IScanData scanData, ILookupTable lookupTable, Method method, ushort thUp = 0, ushort thDown = 0)
        {
            var projection = scanData.GetProjection(Axis.Z, point[Axis.Z]);

            if (projection.Empty)
            {
                throw new ArgumentOutOfRangeException();
            }

            var scalarPoint = point.To2D(Axis.Z);

            switch (method)
            {
            case Method.Average:
                return(GetAverageProbe(scalarPoint, projection, lookupTable, thUp, thDown));

            case Method.MinMax:
                return(GetMinMaxProbe(scalarPoint, projection, lookupTable, thUp, thDown));

            default:
                throw new ArgumentOutOfRangeException(nameof(method), method, null);
            }
        }
Exemple #5
0
        private static Probe GetMinMaxProbe(Point2D scalarPoint, Projection projection, ILookupTable lookupTable, ushort thUp = 0, ushort thDown = 0)
        {
            const int probeHalfWidth = 5;

            ushort min = ushort.MaxValue;
            ushort max = ushort.MinValue;

            for (var x = Math.Max(0, scalarPoint.X - probeHalfWidth); x < Math.Min(projection.Width, scalarPoint.X + probeHalfWidth); x++)
            {
                for (var y = Math.Max(0, scalarPoint.Y - probeHalfWidth); y < Math.Min(projection.Height, scalarPoint.Y + probeHalfWidth); y++)
                {
                    var mappedValue = lookupTable.Map(projection.Pixels[x, y]);

                    if (mappedValue > max)
                    {
                        max = mappedValue;
                    }

                    if (mappedValue < min)
                    {
                        min = mappedValue;
                    }
                }
            }

            return(new Probe()
            {
                _max = (ushort)(max + thUp),
                _min = (ushort)((min - thDown) > 0 ? (min - thDown) : 0)
            });
        }
Exemple #6
0
        private static Probe GetAverageProbe(Point2D scalarPoint, Projection projection, ILookupTable lookupTable, ushort thUp = 0, ushort thDown = 0)
        {
            const int probeHalfWidth = 5;

            int probe      = 0;
            int probeCount = 0;

            for (var x = Math.Max(0, scalarPoint.X - probeHalfWidth);
                 x < Math.Min(projection.Width, scalarPoint.X + probeHalfWidth);
                 x++)
            {
                for (var y = Math.Max(0, scalarPoint.Y - probeHalfWidth);
                     y < Math.Min(projection.Height, scalarPoint.Y + probeHalfWidth);
                     y++)
                {
                    probe += lookupTable.Map(projection.Pixels[x, y]);
                    probeCount++;
                }
            }

            if (probeCount > 0)
            {
                probe /= probeCount;
            }

            return(new Probe()
            {
                _max = (ushort)(probe + thUp),
                _min = (ushort)((probe - thDown) > 0 ? (probe - thDown) : 0)
            });
        }
 public BaseCharacteristicType(string characteristicType, ILookupTable subtype)
 {
     CharacteristicType = characteristicType;
     _subtype           = subtype;
 }