private void button5_Click(object sender, EventArgs e) { int minSpace = 10; var px = OriginalBitmap.GetPixels(); List <int> pxx = new List <int>(); int spacing = 0; for (int i = 0; i < OriginalBitmap.Width; i++) { int h = OriginalBitmap.Height; int totalR = 0; int totalB = 0; int totalG = 0; Color average = Color.Transparent; for (int j = 0; j < h; j++) { var color = OriginalBitmap.GetPixel(i, j); totalR += color.R; totalG += color.G; totalB += color.B; } var oldAverage = average; average = Color.FromArgb(totalR / h, totalG / h, totalB / h); spacing++; if (average.G > 100 && spacing >= minSpace) { pxx.Add(i); spacing = 0; } } var a = OriginalBitmap.Bitmap; foreach (var x in pxx) { for (int i = 0; i < OriginalBitmap.Height; i++) { a.SetPixel(x, i, Color.Violet); } } pictureBox1.Image = a; var p = px.Where(x => x.Value.R == 255).ToArray(); var z = spectrogram.GetFrequency(p[1].Key); // (pictureBox1.Image as Bitmap).SetPixel(p.Key.X, p.Key.Y, Color.Violet); }