Exemple #1
0
        private EViewerHandler(MSPointSet3D argMSPointSet3D)
        {
            //_observers = new List<IMessageObserver>();
            MyOriginalPointSet3D = argMSPointSet3D;
            RawDataPointSet3D = argMSPointSet3D;
            initialize();
            SetColor();
            color_number = 180;
            BaseColor = 4;
            palette = new int[color_number, 3];

            for (int i = 0; i < (color_number / BaseColor); i++)
            {
                palette[i, 0] = color_number;
                palette[i, 1] = i * BaseColor;
                palette[i, 2] = 0;

                palette[i + color_number / BaseColor, 0] = color_number - (i * BaseColor);
                palette[i + color_number / BaseColor, 1] = color_number;
                palette[i + color_number / BaseColor, 2] = 0;

                palette[i + (color_number / BaseColor) * 2, 0] = 0;
                palette[i + (color_number / BaseColor) * 2, 1] = color_number;
                palette[i + (color_number / BaseColor) * 2, 2] = i * BaseColor;

                palette[i + (color_number / BaseColor) * 3, 0] = 0;
                palette[i + (color_number / BaseColor) * 3, 1] = color_number - (i * BaseColor);
                palette[i + (color_number / BaseColor) * 3, 2] = color_number;
            }
        }
Exemple #2
0
        private float[,] MSpointSet3DToArray(MSPointSet3D mspointset, RegionSize PaintRegion)
        {
            RegionSize pointSetRegion = new RegionSize(mspointset.MinX, mspointset.MaxX, mspointset.MaxY, mspointset.MinY);

            float[,] Data = new float[(int)PaintRegion.Width + 1, (int)PaintRegion.Height + 1];
            int[,] DataCount = new int[(int)PaintRegion.Width + 1, (int)PaintRegion.Height + 1];
            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    Data[i, j] = -1;
                    DataCount[i, j] = 0;
                }
            }

            //foreach (MSPoint3D point3D in mspointset.Points3D)
            for (int i = 0; i < mspointset.Count; i++)
            {
                if (DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] == 0)
                {
                    Data[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] = mspointset.Z(i);
                    DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))]++;
                }
                else
                {
                    Data[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] += mspointset.Z(i);
                    DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))]++;
                }
            }
            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    if (Data[i, j] != -1)
                    {
                        Data[i, j] = Data[i, j] / DataCount[i, j];
                    }
                }
            }
            return Data;
        }
Exemple #3
0
        public MSPointSet3D BSpline3DofPepImage(MSPointSet3D mspointset, RegionSize PaintRegion)
        {
            MSPointSet3D interpolatedPointSet3D = new MSPointSet3D();
            RegionSize pointSetRegion = new RegionSize(mspointset.MinX, mspointset.MaxX, mspointset.MaxY, mspointset.MinY);

            if (pointSetRegion.Width * pointSetRegion.Height * PaintRegion.Width * PaintRegion.Height == 0)
            {
                return mspointset;
            }
            float[,] Data;
            Data = MSpointSet3DToArray(mspointset, PaintRegion);

            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                MSPointSet pointset2D = new MSPointSet();
                float MaxIntensity = -1;
                bool empty = true;

                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    if (Data[i, j] != -1)
                    {
                        empty = false;
                        if (Data[i, j] > MaxIntensity)
                        {
                            MaxIntensity = Data[i, j];
                        }
                    }
                }

                if (empty == false)
                {
                    for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                    {
                        if (Data[i, j] == -1)
                        {
                            Data[i, j] = 0;
                        }
                    }
                }
            }

            for (int i = 0; i < (int)PaintRegion.Height + 1; i++)
            {
                MSPointSet pointset2D = new MSPointSet();
                float MaxIntensity = 0;
                for (int j = 0; j < (int)PaintRegion.Width + 1; j++)
                {
                    if (Data[j, i] > MaxIntensity)
                    {
                        MaxIntensity = Data[j, i];
                    }
                }
                if (MaxIntensity > 0/*mspointset.MaxZ/1*/)
                {
                    for (int j = 0; j < (int)PaintRegion.Width + 1; j++)
                    {
                        if (Data[j, i] != -1)
                        {
                            pointset2D.Add(CoordinateTrans.XToTime(PaintRegion, pointSetRegion, j), Data[j, i]);
                        }
                    }
                    pointset2D = BSpline2D(pointset2D, pointSetRegion, PaintRegion, "horizontal");

                    for (int x = 0; x < pointset2D.Count; x++)
                    {
                        if (Data[(int)Math.Round((CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, pointset2D.X(x)))), i] == -1)
                        {
                            Data[(int)Math.Round((CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, pointset2D.X(x)))), i] = pointset2D.Y(x);
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < (int)PaintRegion.Width + 1; j++)
                    {
                        if (Data[j, i] == -1)
                        {
                            Data[j, i] = 0;
                        }
                    }

                }
            }

            Data = NoiseFiltering(Data, (int)PaintRegion.Height + 1, (int)PaintRegion.Width + 1);

            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    if (Data[i, j] != -1)
                    {
                        interpolatedPointSet3D.Add(CoordinateTrans.XToTime(PaintRegion, pointSetRegion, i), CoordinateTrans.YToMass(PaintRegion, pointSetRegion, j), Data[i, j]);
                    }
                    else
                    {
                        interpolatedPointSet3D.Add(CoordinateTrans.XToTime(PaintRegion, pointSetRegion, i), CoordinateTrans.YToMass(PaintRegion, pointSetRegion, j), 0);

                    }
                }
            }
            return interpolatedPointSet3D;
        }
Exemple #4
0
        public MSPointSet3D SubPointSetExtract(RegionSize SR)
        {
            MSPointSet3D tempPointSet = new MSPointSet3D();

            //foreach (MSPoint3D D in MyCurrentPointSet3D.)
            for (int i = 0; i < RawDataPointSet3D.Count; i++)
            {
                if (RawDataPointSet3D._x[i] >= SR.LeftBound && RawDataPointSet3D._x[i] <= SR.RightBound && RawDataPointSet3D._y[i] <= SR.TopBound && RawDataPointSet3D._y[i] >= SR.BottomBound)
                {
                    tempPointSet.Add(RawDataPointSet3D._x[i], RawDataPointSet3D._y[i], RawDataPointSet3D.Z(i));
                }
            }
            return tempPointSet;
        }
Exemple #5
0
 //private EViewerHandler(List<MSPointSet3D> argMSPointSet3D)
 //{
 //    //_observers = new List<IMessageObserver>();
 //    originalPointsetLst = argMSPointSet3D;
 //    rawDataSet3DLst = argMSPointSet3D;
 //    initialize();
 //    SetColor();
 //    color_number = 180;
 //    BaseColor = 4;
 //    palette = new int[color_number, 3];
 //    for (int i = 0; i < (color_number / BaseColor); i++)
 //    {
 //        palette[i, 0] = color_number;
 //        palette[i, 1] = i * BaseColor;
 //        palette[i, 2] = 0;
 //        palette[i + color_number / BaseColor, 0] = color_number - (i * BaseColor);
 //        palette[i + color_number / BaseColor, 1] = color_number;
 //        palette[i + color_number / BaseColor, 2] = 0;
 //        palette[i + (color_number / BaseColor) * 2, 0] = 0;
 //        palette[i + (color_number / BaseColor) * 2, 1] = color_number;
 //        palette[i + (color_number / BaseColor) * 2, 2] = i * BaseColor;
 //        palette[i + (color_number / BaseColor) * 3, 0] = 0;
 //        palette[i + (color_number / BaseColor) * 3, 1] = color_number - (i * BaseColor);
 //        palette[i + (color_number / BaseColor) * 3, 2] = color_number;
 //    }
 //    smoothedSetLst = new List<MSPointSet3D>();
 //    foreach (MSPointSet3D msp3d in RawDataPointSet3DList)
 //    {
 //        BSpline BS = new BSpline();
 //        MSPointSet MSP = new MSPointSet();
 //        MSP.AddMSPoints(msp3d._x, msp3d._z);
 //        MSPointSet smoothedMSP = BS.BSpline2D(MSP, new RegionSize(MSP.X(0),MSP.X(MSP.Count-1),MSP.Y(MSP.MaxIntensityIdx),MSP.Y(MSP.MinIntensityIdx)), _bmpRegion);
 //        List<float> mz = new List<float>();
 //        for(int  i =0;i<smoothedMSP.XLst.Count;i++)
 //        {
 //            mz.Add(msp3d._y[0]);
 //        }
 //        smoothedSetLst.Add(new MSPointSet3D(smoothedMSP.XLst, mz, smoothedMSP.YLst));
 //    }
 //}
 public MSPointSet3D smoothing(MSPointSet3D current)
 {
     MSPointSet3D result3D = new MSPointSet3D();
     BSpline BS = new BSpline();
     result3D = BS.BSpline3DofPepImage(current, BmpRegion);
     return result3D;
 }
Exemple #6
0
        public static EViewerHandler Create3DHandler(MSPointSet3D argMSPointSet3D)
        {
            EViewerHandler _EViewerHandler = new EViewerHandler(argMSPointSet3D);

            return _EViewerHandler;
        }