Exemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables

            int M = 0;

            // Access the input parameters
            if (!DA.GetData(0, ref M))
            {
                return;
            }

            mFilter Filter = new mFilter();

            switch (M)
            {
            case 0:
                Filter = new mNormalizeExtents();
                break;

            case 1:
                Filter = new mNormalizeHistogram();
                break;
            }


            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, W);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables

            Interval Ga = new Interval(0, 255);
            Interval Gb = new Interval(0, 255);

            // Access the input parameters
            if (!DA.GetData(0, ref Ga))
            {
                return;
            }
            if (!DA.GetData(1, ref Gb))
            {
                return;
            }

            mFilter Filter = new mFilter();

            Filter = new mAdjustLevelsGray(new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1));


            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, W);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            int     T = 10;
            int     S = 5;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:
                Filter = new mThresholdOtsu();
                break;

            case 1:
                Filter = new mThresholdSIS();
                break;

            case 2:
                if (!DA.GetData(1, ref T))
                {
                    return;
                }
                Filter = new mThresholdSimple(T);
                break;

            case 3:
                if (!DA.GetData(1, ref T))
                {
                    return;
                }
                if (!DA.GetData(2, ref S))
                {
                    return;
                }
                Filter = new mThresholdIterative(T, S);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 4
0
 public void AddFilter(mFilter Filter)
 {
     if (Filter.BitmapType < BitmapType)
     {
         BitmapType = Filter.BitmapType;
     }
     Sequence.Add(Filter.filter);
 }
Exemplo n.º 5
0
        public mApply(Bitmap SourceBitmap, mFilter Filter, int Width, int Height)
        {
            Bitmap TargetBitmap = (Bitmap)SourceBitmap.Clone();

            TargetBitmap = new mSetFormat(TargetBitmap, Filter.BitmapType).ModifiedBitmap;
            TargetBitmap = Filter.filter.Apply(TargetBitmap);

            ModifiedBitmap = (Bitmap)TargetBitmap.Clone();
            ModifiedBitmap.SetResolution(Width, Height);
            ModifiedBitmap = Accord.Imaging.Image.Clone(ModifiedBitmap, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        }
Exemplo n.º 6
0
        public mApply(Bitmap SourceBitmap, mFilter Filter)
        {
            Bitmap TargetBitmap = (Bitmap)SourceBitmap.Clone();

            TargetBitmap = new mSetFormat(TargetBitmap, Filter.BitmapType).ModifiedBitmap;
            TargetBitmap = Filter.filter.Apply(TargetBitmap);

            ModifiedBitmap = (Bitmap)TargetBitmap.Clone();
            ModifiedBitmap.CopyResolutionFrom(SourceBitmap);
            ModifiedBitmap = Accord.Imaging.Image.Clone(ModifiedBitmap, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            //ModifiedBitmap.SetResolution(SourceBitmap.HorizontalResolution, SourceBitmap.VerticalResolution);
        }
Exemplo n.º 7
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            int     M = 0;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }
            mFilter Filter = new mFilter();


            if (M != ModeIndex)
            {
                ModeIndex = M;
                UpdateMessage();
            }

            if (M < 4)
            {
                Filter = new mExtractARGBChannel((short)M);
            }
            else
            {
                Filter = new mExtractYCbCrChannel((short)(M - 4));
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 8
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            int M = 0;
            Interval U = new Interval(50, 1000);
            Interval V = new Interval(50, 1000);

            // Access the input parameters 
            if (!DA.GetData(0, ref Z)) return;
            if (!DA.GetData(1, ref M)) return;
            if (!DA.GetData(2, ref U)) return;
            if (!DA.GetData(3, ref V)) return;

            Bitmap A = null;
            if (Z != null) { Z.CastTo(out A); }
            Bitmap B = new Bitmap(A);

            mFilter Filter = new mFilter();

            wDomain X = new wDomain(U.T0,U.T1);
            wDomain Y = new wDomain(V.T0, V.T1);

            switch (M)
            {
                case 0:
                    Filter = new mFigureUnique(X, Y);
                    break;
                case 1:
                    Filter = new mFigureFilter(X, Y);
                    break;
                case 2:
                   Filter = new mFigureCorners(Color.Red);
                    break;
            }

            B = new mApply(A, Filter).ModifiedBitmap;

            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 9
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;

            System.Drawing.Color S = System.Drawing.Color.Red;
            System.Drawing.Color T = System.Drawing.Color.Blue;
            double R = 100;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref S))
            {
                return;
            }
            if (!DA.GetData(2, ref T))
            {
                return;
            }
            if (!DA.GetData(3, ref R))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            Filter = new mFilterEuclideanColor(new wColor(S.R, S.G, S.B), new wColor(T.R, T.G, T.B), (short)R);

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 10
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            bool    H = false;
            bool    V = false;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref H))
            {
                return;
            }
            if (!DA.GetData(2, ref V))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            Filter = new mMirror(H, V);

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 11
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables

            int M = 0;
            int D = 32;

            // Access the input parameters
            if (!DA.GetData(0, ref M))
            {
                return;
            }
            if (!DA.GetData(1, ref D))
            {
                return;
            }

            mFilter Filter = new mFilter();

            switch (M)
            {
            case 0:
                Filter = new mStreakHorizontal(D);
                break;

            case 1:
                Filter = new mStreakVertical(D);
                break;
            }


            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, W);
        }
Exemplo n.º 12
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            double  V = 0;

            int M = 0;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }
            if (!DA.GetData(2, ref V))
            {
                return;
            }

            M = M % 10;

            if (M != ModeIndex)
            {
                ModeIndex = M;
                UpdateMessage();
            }

            if (M < 5)
            {
                Params.Input[2].NickName    = "T";
                Params.Input[2].Name        = "Adjust Value";
                Params.Input[2].Description = "Suggested Range [0,1]";
            }
            else
            {
                Params.Input[2].NickName    = "-";
                Params.Input[2].Name        = "Not Used";
                Params.Input[2].Description = "Not used by this filter";
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }
            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            default:
                Filter = new mAdjustBrightness((int)(V * 255));
                break;

            case 1:
                Filter = new mAdjustContrast((int)(V * 255));
                break;

            case 2:
                Filter = new mAdjustGamma(0.1 + (V * 4.9));
                break;

            case 3:
                Filter = new mAdjustHue((int)(V * 360));
                break;

            case 4:
                Filter = new mAdjustSaturation((float)(-1 + V * 2));
                break;

            case 5:
                Filter = new mAdjustWhitePatch();
                break;

            case 6:
                Filter = new mAdjustGrayWorld();
                break;

            case 7:
                Filter = new mAdjustHistogramEqualization();
                break;

            case 8:
                Filter = new mAdjustContrastStretch();
                break;

            case 9:
                Filter = new mAdjustInvert();
                break;
            }


            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 13
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:
                Filter = new mSharpenSimple();
                break;

            case 1:
                int    K1 = 11;
                double S1 = 4;
                if (!DA.GetData(1, ref K1))
                {
                    return;
                }
                if (!DA.GetData(2, ref S1))
                {
                    return;
                }
                Filter = new mSharpenGaussian(K1, S1);
                break;

            case 2:
                int B2 = 10;
                if (!DA.GetData(1, ref B2))
                {
                    return;
                }
                Filter = new mSharpenHighBoost(B2);
                break;

            case 3:
                int F3 = 1;
                if (!DA.GetData(1, ref F3))
                {
                    return;
                }
                Filter = new mSmoothAdaptive(F3);
                break;

            case 4:
                int    K4 = 7;
                double S4 = 10;
                double F4 = 60;
                double P4 = 0.5;
                if (!DA.GetData(1, ref K4))
                {
                    return;
                }
                if (!DA.GetData(2, ref S4))
                {
                    return;
                }
                if (!DA.GetData(3, ref F4))
                {
                    return;
                }
                if (!DA.GetData(4, ref P4))
                {
                    return;
                }
                Filter = new mSmoothBilateral(K4, S4, F4, P4);
                break;

            case 5:
                Filter = new mSmoothConservative();
                break;

            case 6:
                int D6 = 9;
                if (!DA.GetData(1, ref D6))
                {
                    return;
                }
                Filter = new mSmoothMean(D6);
                break;

            case 7:
                int K7 = 3;
                if (!DA.GetData(1, ref K7))
                {
                    return;
                }
                Filter = new mSmoothMedian(K7);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 14
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo  Z = null;
            int      I = 0;
            int      J = 0;
            bool     C = true;
            bool     D = true;
            Interval X = new Interval(0, 20);
            Interval Y = new Interval(0, 20);


            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:
                Filter = new mErosionSimple();
                break;

            case 1:
                Filter = new mErosionDilation();
                break;

            case 2:
                Filter = new mErosionOpening();
                break;

            case 3:
                Filter = new mErosionClosing();
                break;

            case 4:
                Filter = new mErosionHatTop();
                break;

            case 5:
                Filter = new mErosionHatBottom();
                break;

            case 6:
                if (!DA.GetData(1, ref I))
                {
                    return;
                }
                if (!DA.GetData(2, ref J))
                {
                    return;
                }
                Filter = new mErosionSkeleton(I, J);
                break;

            case 7:
                if (!DA.GetData(1, ref I))
                {
                    return;
                }
                if (!DA.GetData(2, ref C))
                {
                    return;
                }
                Filter = new mStreakHorizontal(I, C);
                break;

            case 8:
                if (!DA.GetData(1, ref I))
                {
                    return;
                }
                if (!DA.GetData(2, ref C))
                {
                    return;
                }
                Filter = new mStreakVertical(I, C);
                break;

            case 9:
                if (!DA.GetData(1, ref I))
                {
                    return;
                }
                if (!DA.GetData(2, ref J))
                {
                    return;
                }
                if (!DA.GetData(3, ref C))
                {
                    return;
                }
                Filter = new mErosionFill(I, J, C);
                break;

            case 10:
                if (!DA.GetData(1, ref X))
                {
                    return;
                }
                if (!DA.GetData(2, ref Y))
                {
                    return;
                }
                if (!DA.GetData(3, ref C))
                {
                    return;
                }
                Filter = new mFigureFilter(new wDomain(X.T0, X.T1), new wDomain(Y.T0, Y.T1), C);
                break;

            case 11:
                if (!DA.GetData(1, ref X))
                {
                    return;
                }
                if (!DA.GetData(2, ref Y))
                {
                    return;
                }
                if (!DA.GetData(3, ref C))
                {
                    return;
                }
                if (!DA.GetData(3, ref D))
                {
                    return;
                }
                Filter = new mFigureUnique(new wDomain(X.T0, X.T1), new wDomain(Y.T0, Y.T1), C, D);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 15
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:    //Blur
                Filter = new mBlur();
                break;

            case 1:    //Jitter
                int R3 = 10;
                if (!DA.GetData(1, ref R3))
                {
                    return;
                }
                Filter = new mEffectJitter(R3);
                break;

            case 2:    //Daube
                int R4 = 10;
                if (!DA.GetData(1, ref R4))
                {
                    return;
                }
                Filter = new mEffectDaube(R4);
                break;

            case 3:    //Kuwahara
                int R7 = 5;
                if (!DA.GetData(1, ref R7))
                {
                    return;
                }
                Filter = new mEffectKuwahara(R7);
                break;

            case 4:    //Additive
                int R5 = 5;
                if (!DA.GetData(1, ref R5))
                {
                    return;
                }
                Filter = new mNoiseAdditive(new Wind.Types.wDomain(0, R5));
                break;

            case 5:    //Salt&Pepper
                int R6 = 5;
                if (!DA.GetData(1, ref R6))
                {
                    return;
                }
                Filter = new mNoiseSandP(R6);
                break;

            case 6:    //Box Blur
                int H1 = 3;
                int V1 = 3;
                if (!DA.GetData(1, ref H1))
                {
                    return;
                }
                if (!DA.GetData(2, ref V1))
                {
                    return;
                }
                Filter = new mBlurBox((byte)H1, (byte)V1);
                break;

            case 7:    //Gaussian Blur
                double S2 = 4.0;
                int    K2 = 11;
                if (!DA.GetData(1, ref S2))
                {
                    return;
                }
                if (!DA.GetData(2, ref K2))
                {
                    return;
                }
                Filter = new mBlurGaussian(S2, K2);
                break;

            case 8:    //Pixelate
                int H8 = 3;
                int W8 = 3;
                if (!DA.GetData(1, ref H8))
                {
                    return;
                }
                if (!DA.GetData(2, ref W8))
                {
                    return;
                }
                Filter = new mEffectPixelate(H8, W8);
                break;

            case 9:    //Posterization
                int D9 = 5;
                int M9 = 0;
                if (!DA.GetData(1, ref D9))
                {
                    return;
                }
                if (!DA.GetData(2, ref M9))
                {
                    return;
                }
                Filter = new mEffectPosterization((byte)D9, M9);
                break;

            case 10:    //Ripple
                int X10 = 10;
                int Y10 = 5;
                int H10 = 5;
                int W10 = 5;
                if (!DA.GetData(1, ref X10))
                {
                    return;
                }
                if (!DA.GetData(2, ref Y10))
                {
                    return;
                }
                if (!DA.GetData(3, ref H10))
                {
                    return;
                }
                if (!DA.GetData(4, ref W10))
                {
                    return;
                }
                Filter = new mEffectRipple(X10, Y10, H10, W10);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 16
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo  Z  = null;
            Color    C  = Color.Black;
            Interval Rc = new Interval(0, 255);
            Interval Gc = new Interval(100, 255);
            Interval Bc = new Interval(100, 255);

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref C))
            {
                return;
            }
            if (!DA.GetData(2, ref Rc))
            {
                return;
            }
            if (!DA.GetData(3, ref Gc))
            {
                return;
            }
            if (!DA.GetData(4, ref Bc))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }
            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:
                Filter = new mFilterARGBChannel(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut);
                break;

            case 1:
                Filter = new mFilterARGBColor(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut, C);
                break;

            case 2:
                Filter = new mFilterHSL(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut, C);
                break;

            case 3:
                Filter = new mFilterYCbCrColor(new wDomain(Rc.T0, Rc.T1), new wDomain(Gc.T0, Gc.T1), new wDomain(Bc.T0, Bc.T1), ModeInOut, C);

                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 17
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo X = null;
            int     M = 0;
            double  R = 0.2125;
            double  G = 0.7154;
            double  B = 0.0721;

            // Access the input parameters
            if (!DA.GetData(0, ref X))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }

            if (M != ModeIndex)
            {
                ModeIndex = M;
                UpdateMessage();
                if (M == 0)
                {
                    SetParameter(2, "Red", "R", "---");
                    SetParameter(3, "Green", "G", "---");
                    SetParameter(4, "Blue", "B", "---");
                }
                else
                {
                    SetParameter(2, "Not Used", "-", "Not used by this filter");
                    SetParameter(3, "Not Used", "-", "Not used by this filter");
                    SetParameter(4, "Not Used", "-", "Not used by this filter");
                }
            }

            if (!DA.GetData(2, ref R))
            {
                return;
            }
            if (!DA.GetData(3, ref G))
            {
                return;
            }
            if (!DA.GetData(4, ref B))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (X != null)
            {
                X.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            Filter = new mGrayscale(R, G, B, (mGrayscale.GrayscaleModes)M);

            Bitmap  C = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, C);
            DA.SetData(1, W);
        }
Exemplo n.º 18
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            int     M = 0;
            IGH_Goo Z = null;
            double  R = 0;
            double  D = 1;
            int     X = 600;
            int     Y = 600;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }
            if (!DA.GetData(2, ref R))
            {
                return;
            }
            if (!DA.GetData(3, ref D))
            {
                return;
            }
            if (!DA.GetData(4, ref X))
            {
                return;
            }
            if (!DA.GetData(5, ref Y))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            if (M != ModeIndex)
            {
                ModeIndex = M;
                UpdateMessage();
            }

            switch (M)
            {
            case 0:
                Filter = new mPolarToPolar(R, D, X, Y);
                break;

            case 1:
                Filter = new mPolarToRect(R, D, X, Y);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 19
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo  Z  = null;
            Interval LA = new Interval(0.0, 1.0);
            Interval LB = new Interval(0.0, 1.0);
            Interval SA = new Interval(0.0, 1.0);
            Interval SB = new Interval(0.0, 1.0);

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref LA))
            {
                return;
            }
            if (!DA.GetData(2, ref LB))
            {
                return;
            }
            if (!DA.GetData(3, ref SA))
            {
                return;
            }
            if (!DA.GetData(4, ref SB))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            default:
                Filter = new mFilterHSLLinear(new wDomain(SA.T0, SA.T1), new wDomain(SB.T0, SB.T1), new wDomain(LA.T0, LA.T1), new wDomain(LB.T0, LB.T1));
                break;

            case 1:
                Interval TA = new Interval(0.0, 1.0);
                Interval TB = new Interval(0.0, 1.0);
                if (!DA.GetData(5, ref TA))
                {
                    return;
                }
                if (!DA.GetData(6, ref TB))
                {
                    return;
                }

                Filter = new mFilterYCbCrLinear(new wDomain(LA.T0, LA.T1), new wDomain(SA.T0, SA.T1), new wDomain(TA.T0, TA.T1), new wDomain(LB.T0, LB.T1), new wDomain(SB.T0, SB.T1), new wDomain(TB.T0, TB.T1));
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 20
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            int     M = 0;
            Color   T = Color.Red;
            Color   F = Color.Black;
            int     X = 10;
            Point3d P = new Point3d(1, 1, 0);

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }
            if (!DA.GetData(2, ref T))
            {
                return;
            }
            if (!DA.GetData(3, ref F))
            {
                return;
            }
            if (!DA.GetData(4, ref X))
            {
                return;
            }
            if (!DA.GetData(5, ref P))
            {
                return;
            }

            M = M % 10;

            if (M != ModeIndex)
            {
                ModeIndex = M;
                UpdateMessage();
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }
            mFilter Filter = new mFilter();

            switch (M)
            {
            case 0:
                Filter = new mFillColor(T, F, (int)P.X, (int)P.Y);

                break;

            case 1:
                Filter = new mFillMean(T, (int)P.X, (int)P.Y);

                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 21
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            int     M = 0;
            double  P = -1;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }
            if (!DA.GetData(2, ref P))
            {
                return;
            }

            if (M != ModeIndex)
            {
                ModeIndex = M;
                UpdateMessage();
                if (M > 1)
                {
                    SetParameter(2, "Threshold", "T", "" + V[M] + "");
                }
                else
                {
                    SetParameter(2, "Not Used", "-", "Not used by this filter");
                }
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:
                Filter = new mDitherBayer();
                break;

            case 1:
                Filter = new mDitherOrdered();
                break;

            case 2:
                if (P < 0)
                {
                    P = 32;
                }
                Filter = new mDitherBurkes((byte)P);
                break;

            case 3:
                if (P < 0)
                {
                    P = 16;
                }
                Filter = new mDitherFloydSteinberg((byte)P);
                break;

            case 4:
                if (P < 0)
                {
                    P = 48;
                }
                Filter = new mDitherJarvisJudiceNinke((byte)P);
                break;

            case 5:
                if (P < 0)
                {
                    P = 32;
                }
                Filter = new mDitherSierra((byte)P);
                break;

            case 6:
                if (P < 0)
                {
                    P = 42;
                }
                Filter = new mDitherStucki((byte)P);
                break;

            case 7:
                if (P < 0)
                {
                    P = 50;
                }
                Filter = new mDitherThresholdCarry((byte)P);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 22
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;
            int     M = 0;
            int     R = 90;
            bool    F = true;
            Color   X = Color.Black;

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref M))
            {
                return;
            }
            if (!DA.GetData(2, ref R))
            {
                return;
            }
            if (!DA.GetData(3, ref F))
            {
                return;
            }
            if (!DA.GetData(4, ref X))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (M)
            {
            case 0:
                Filter = new mRotateBicubic(R, F, X);
                break;

            case 1:

                Filter = new mRotateBilinear(R, F, X);
                break;

            case 2:

                Filter = new mRotateNearistNeighbor(R, F, X);
                break;
            }

            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 23
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo X = null;
            int     L = 0;
            int     H = 0;
            int     S = 1;
            bool    Z = false;

            // Access the input parameters
            if (!DA.GetData(0, ref X))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (X != null)
            {
                X.CastTo(out A);
            }

            mFilter Filter = new mFilter();

            switch (ModeIndex)
            {
            case 0:
                Filter = new mEdgeDifference();
                break;

            case 1:
                Filter = new mEdgeHomogenity();
                break;

            case 2:
                if (!DA.GetData(1, ref Z))
                {
                    return;
                }
                Filter = new mEdgeSobel(Z);
                break;

            case 3:
                if (!DA.GetData(1, ref S))
                {
                    return;
                }
                if (!DA.GetData(2, ref L))
                {
                    return;
                }
                if (!DA.GetData(3, ref Z))
                {
                    return;
                }
                Filter = new mEdgeSimple(L, S, Z);
                break;

            case 4:
                if (!DA.GetData(1, ref S))
                {
                    return;
                }
                if (!DA.GetData(2, ref L))
                {
                    return;
                }
                if (!DA.GetData(3, ref H))
                {
                    return;
                }
                Filter = new mEdgeCanny(L, H, S);
                break;
            }


            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }
Exemplo n.º 24
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo V = null;
            int     D = 25;
            int     G = 18;
            Color   Y = Color.Red;

            // Access the input parameters
            if (!DA.GetData(0, ref V))
            {
                return;
            }
            if (!DA.GetData(1, ref D))
            {
                return;
            }
            if (!DA.GetData(2, ref G))
            {
                return;
            }
            if (!DA.GetData(3, ref Y))
            {
                return;
            }

            Bitmap A = null;

            if (V != null)
            {
                V.CastTo(out A);
            }
            Bitmap B = new Bitmap(A);


            List <wPoint> Points = new List <wPoint>();

            mFilter Filter = new mFilter();

            switch (FilterMode)
            {
            case 0:
                mAnalyzeCornersSusan Scorner = new mAnalyzeCornersSusan(A, Y, D, G);
                Points = Scorner.Points;
                Filter = Scorner;
                break;

            case 1:
                mAnalyzeCornersMoravec Mcorner = new mAnalyzeCornersMoravec(A, Y, D);
                Points = Mcorner.Points;
                Filter = Mcorner;
                break;
            }



            B = new mApply(A, Filter).ModifiedBitmap;

            wObject W = new wObject(Filter, "Macaw", Filter.Type);

            List <Point3d> P = new List <Point3d>();

            foreach (wPoint X in Points)
            {
                P.Add(new Point3d(X.X, X.Y, X.Z));
            }

            DA.SetData(0, B);
            DA.SetData(1, W);
            DA.SetDataList(2, P);
        }
Exemplo n.º 25
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare variables
            IGH_Goo Z = null;

            Interval Ra = new Interval(0, 255);
            Interval Ga = new Interval(0, 255);
            Interval Ba = new Interval(0, 255);
            Interval Xa = new Interval(0, 255);

            Interval Rb = new Interval(0, 255);
            Interval Gb = new Interval(0, 255);
            Interval Bb = new Interval(0, 255);
            Interval Xb = new Interval(0, 255);

            // Access the input parameters
            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(1, ref Ra))
            {
                return;
            }
            if (!DA.GetData(2, ref Rb))
            {
                return;
            }

            Bitmap A = new Bitmap(10, 10);

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            mFilter Filter = new mFilter();


            switch (ModeIndex)
            {
            case 0:
                if (TypeIndex == 0)
                {
                    Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1));
                }
                else
                {
                    Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1));
                }
                break;

            case 1:
                if (TypeIndex == 0)
                {
                    Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1));
                }
                else
                {
                    Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1));
                }
                break;

            case 2:
                if (!DA.GetData(3, ref Ga))
                {
                    return;
                }
                if (!DA.GetData(4, ref Gb))
                {
                    return;
                }
                if (!DA.GetData(5, ref Ba))
                {
                    return;
                }
                if (!DA.GetData(6, ref Bb))
                {
                    return;
                }

                if (TypeIndex == 0)
                {
                    Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1));
                }
                else
                {
                    Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1));
                }
                break;

            case 3:
                if (!DA.GetData(3, ref Ga))
                {
                    return;
                }
                if (!DA.GetData(4, ref Gb))
                {
                    return;
                }
                if (!DA.GetData(5, ref Ba))
                {
                    return;
                }
                if (!DA.GetData(6, ref Bb))
                {
                    return;
                }
                if (!DA.GetData(7, ref Xa))
                {
                    return;
                }
                if (!DA.GetData(8, ref Xb))
                {
                    return;
                }

                if (TypeIndex == 0)
                {
                    Filter = new mAdjustLevels(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1), new wDomain(Xa.T0, Xa.T1), new wDomain(Xb.T0, Xb.T1));
                }
                else
                {
                    Filter = new mAdjustLevels16bpp(new wDomain(Ra.T0, Ra.T1), new wDomain(Rb.T0, Rb.T1), new wDomain(Ga.T0, Ga.T1), new wDomain(Gb.T0, Gb.T1), new wDomain(Ba.T0, Ba.T1), new wDomain(Bb.T0, Bb.T1), new wDomain(Xa.T0, Xa.T1), new wDomain(Xb.T0, Xb.T1));
                }
                break;
            }


            Bitmap  B = new mApply(A, Filter).ModifiedBitmap;
            wObject W = new wObject(Filter, "Macaw", Filter.Type);


            DA.SetData(0, B);
            DA.SetData(1, W);
        }