Пример #1
0
		public void DrawMatrixGraph(string fileName) {
			
			GraphPane myPane;
			RectangleF rect = new RectangleF( 0, 0, 1200, 600 );
			
			PointPairList ppl = new PointPairList();
			if (columns == 1) {
				myPane = new GraphPane( rect, "Matrix", "Rows", "Value" );
				for(int i = 0; i < rows; i++) {
					ppl.Add(i, d[i,0]);
				}
				LineItem myCurve = myPane.AddCurve("", ppl.Clone(), Color.Black, SymbolType.None);
			} else if (rows == 1) {
				myPane = new GraphPane( rect, "Matrix", "Columns", "Value" );
				for(int i = 0; i < columns; i++) {
					ppl.Add(i, d[0,i]);
				}
				LineItem myCurve = myPane.AddCurve("", ppl.Clone(), Color.Black, SymbolType.None);
			} else if (columns > rows) {
				myPane = new GraphPane( rect, "Matrix", "Columns", "Value" );
				for(int i = 0; i < rows; i++)
				{
					ppl.Clear();
					for(int j = 0; j < columns; j++)
					{
						ppl.Add(j, d[i,j]);
					}
					Color color = ColorUtils.MatlabGraphColor(i);
					LineItem myCurve = myPane.AddCurve("", ppl.Clone(), color, SymbolType.None);
				}
			} else { // (columns < rows)
				myPane = new GraphPane( rect, "Matrix", "Rows", "Value" );
				for(int j = 0; j < columns; j++)
				{
					ppl.Clear();
					for(int i = 0; i < rows; i++)
					{
						ppl.Add(i, d[i,j]);
					}
					Color color = ColorUtils.MatlabGraphColor(j);
					LineItem myCurve = myPane.AddCurve("", ppl.Clone(), color, SymbolType.None);
				}
			}

			Bitmap bm = new Bitmap( 1, 1 );
			using ( Graphics g = Graphics.FromImage( bm ) )
				myPane.AxisChange( g );
			
			myPane.GetImage().Save(fileName, ImageFormat.Png);
		}
Пример #2
0
		public void DrawMelFiltersBank(string fileName) {
			GraphPane myPane = new GraphPane( new RectangleF( 0, 0, 1200, 600 ),
			                                 "Mel Filter Bank", "X Title", "Y Title" );

			Random random = new Random();
			
			PointPairList ppl = new PointPairList();
			double[] filterSpectrum;
			foreach(var filter in filters) {
				ppl.Clear();
				if (filter.IsEnabled()) {
					filterSpectrum = filter.GetFilterSpectrum();
					for (int i = 0; i < 200; i++) {
						ppl.Add(i, filterSpectrum[i]);
					}
					Color color = Color.FromArgb(random.Next(0, 255), random.Next(0,255),random.Next(0,255));
					LineItem myCurve = myPane.AddCurve("", ppl.Clone(), color, SymbolType.None );
				}
			}

			Bitmap bm = new Bitmap( 1, 1 );
			using ( Graphics g = Graphics.FromImage( bm ) )
				myPane.AxisChange( g );
			
			myPane.GetImage().Save(fileName, ImageFormat.Png);
		}
        public List<PointPairList> rectasEjeReal()
        {
            rectasEje = new List<PointPairList>();
            PointPairList semiRecta = new PointPairList();

            if ((n + m) % 2 != 0)                   //Si el numero de ceros y polos es Impar la ultima raiz va hacia el infinito
            {
                for (int i = 0; i < pYcOrdenados[0].Length-1; i += 2)      //Se los agrupa en pares y se crean rectas
                {
                    semiRecta.Clear();
                    for (double d = pYcOrdenados[0][i]; d >= pYcOrdenados[0][i + 1]; d -= pasoX)
                    {
                        PointPair pto = new PointPair(d, 0);
                        pto.Z = calculaK(pto);
                        semiRecta.Add(pto);
                    }
                    rectasEje.Add(semiRecta.Clone());
                }
                //Esta raiz queda sola y va hacia el infinito
                semiRecta.Clear();
                for (double d = pYcOrdenados[0][pYcOrdenados[0].Length-1]; d >= this.InicioEjeX; d-= pasoX)
                {
                    PointPair pto = new PointPair(d, 0);
                    pto.Z = calculaK(pto);
                    semiRecta.Add(pto);
                }
                rectasEje.Add(semiRecta.Clone());
            }
            else
            {
                for (int i = 0; i < pYcOrdenados[0].Length; i += 2)      //Se los agrupa en pares y se crean rectas
                {
                    semiRecta.Clear();
                    for (double d = pYcOrdenados[0][i]; d >= pYcOrdenados[0][i + 1]; d -= pasoX)
                    {
                        PointPair pto = new PointPair(d, 0);
                        pto.Z = calculaK(pto);
                        semiRecta.Add(pto);
                    }
                    rectasEje.Add(semiRecta.Clone());
                }

            }

            return rectasEje;
        }
Пример #4
0
		/// <summary>
		/// Draw the matrix as a image graph
		/// Imitating Matlabs plot(M), where M is the matrix
		/// </summary>
		/// <param name="fileName">filename</param>
		public void DrawMatrixGraph(string fileName, bool forceUseRows=false) {
			
			GraphPane myPane;
			var rect = new RectangleF( 0, 0, 1200, 600 );
			
			var ppl = new PointPairList();
			if (columnCount == 1) {
				myPane = new GraphPane( rect, "Matrix", "Rows", "Value" );
				for(int i = 0; i < rowCount; i++) {
					ppl.Add(i, matrixData[i][0]);
				}
				LineItem myCurve = myPane.AddCurve("", ppl.Clone(), Color.Black, SymbolType.None);
			} else if (rowCount == 1) {
				myPane = new GraphPane( rect, "Matrix", "Columns", "Value" );
				for(int i = 0; i < columnCount; i++) {
					ppl.Add(i, matrixData[0][i]);
				}
				LineItem myCurve = myPane.AddCurve("", ppl.Clone(), Color.Black, SymbolType.None);
			} else if (!forceUseRows && columnCount > rowCount) {
				myPane = new GraphPane( rect, "Matrix", "Columns", "Value" );
				for(int i = 0; i < rowCount; i++)
				{
					ppl.Clear();
					for(int j = 0; j < columnCount; j++)
					{
						ppl.Add(j, matrixData[i][j]);
					}
					Color color = ColorUtils.MatlabGraphColor(i);
					LineItem myCurve = myPane.AddCurve("", ppl.Clone(), color, SymbolType.None);
				}
			} else { // (columns < rows)
				myPane = new GraphPane( rect, "Matrix", "Rows", "Value" );
				for(int j = 0; j < columnCount; j++)
				{
					ppl.Clear();
					for(int i = 0; i < rowCount; i++)
					{
						ppl.Add(i, matrixData[i][j]);
					}
					Color color = ColorUtils.MatlabGraphColor(j);
					LineItem myCurve = myPane.AddCurve("", ppl.Clone(), color, SymbolType.None);
				}
			}

			var bm = new Bitmap( 1, 1 );
			using ( Graphics g = Graphics.FromImage( bm ) ) {
				myPane.AxisChange( g );
			}
			
			myPane.GetImage().Save(fileName, ImageFormat.Png);
		}