Пример #1
0
        private void Initialize()
        {
            Surface   surface = this.EnvironmentParameters.SourceSurface;
            Rectangle bounds  = this.EnvironmentParameters.GetSelection(surface.Bounds).GetBoundsInt();

            if (this._cachedCharacteristics == null)
            {
                this._cachedCharacteristics = new CachedValues <TensorCharacteristics>(bounds.Height, this.GetCharacteristics);
            }

            lock (this)
            {
                if (this._taskSTField == null)
                {
                    this._cancelToken = new EdgeDetectionEffect();
                    this._taskSTField = StructurTensorField.FromSurfaceAsync(surface, bounds, this._diffX.GetNormalized(), null, this._cancelToken);
                    this._cachedCharacteristics.Invalidate();
                }
            }
        }
Пример #2
0
        private void GetCharacteristics(Rectangle rect, TensorCharacteristics[,] values)
        {
            StructurTensorField stField = this._taskSTField.Result;
            Rectangle           bounds  = this.EnvironmentParameters.GetSelection(this.SrcArgs.Bounds).GetBoundsInt();

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    StructurTensor tensor;
                    if (this._weight != null)
                    {
                        tensor = stField.Convolve(x - bounds.Left, y - bounds.Top, this._weight);
                    }
                    else
                    {
                        tensor = stField[x - bounds.Left, y - bounds.Top];
                    }

                    values[x - rect.Left, y - rect.Top] = tensor.GetCharacteristics();
                }
            }
        }