private void button4_Click(object sender, EventArgs e) { int max = 80; CircleCreator cc = new CircleCreator(max, max); Circle c = new Circle(max, max, max / 2, cc.PointsOnCircle.ToArray()); EmiterGenerator eg = new EmiterGenerator(5, c); List <EmiterDetectorsSystem> systems = new List <EmiterDetectorsSystem>(); eg.Emiters.ForEach(em => { DetectorsGenerator dg = new DetectorsGenerator(20, 60, c, em); systems.Add(new EmiterDetectorsSystem(em, dg.Detectors)); #region debug console //int[,] debugTab = new int[max + 1, max + 1]; //for (int i = 0; i < max + 1; i++) //{ // for (int j = 0; j < max + 1; j++) // { // debugTab[i, j] = 0; // } //} //debugTab[em.Point.X, em.Point.Y] = 3; //dg.Detectors.ForEach(d => debugTab[d.Point.X, d.Point.Y] = 1); //EmiterDetectorsSystem s = systems.Last(); //s.Detectors.ForEach(de => s.GetLineForDetector(de).Points.ForEach(point => debugTab[point.X, point.Y] = 4)); //for (int i = 0; i < max + 1; i++) //{ // for (int j = 0; j < max + 1; j++) // { // Console.Write(debugTab[i, j]); // } // Console.WriteLine(); //} //Console.ReadLine(); //Console.Clear(); #endregion }); BitmapToBlackAndWhiteConverter converter = new BitmapToBlackAndWhiteConverter(this.baseImage.Bitmap); }
private void DoRandonTransform(BaseImage image, int n, double a, int l, bool useKeyPoints) { int maxX = image.Bitmap.Width - 1; int maxY = image.Bitmap.Height - 1; int radius = image.Bitmap.Width / 2 - 1; CircleCreator cc = new CircleCreator(maxX, maxY); Circle circle = new Circle(maxX, maxY, radius, cc.PointsOnCircle.ToArray()); IEmiterGenerator eg = CreateEmiterGenerator(useKeyPoints, a, circle, maxX, maxY, radius); List <EmiterDetectorsSystem> systems = new List <EmiterDetectorsSystem>(); BitmapToBlackAndWhiteConverter blackBitmap = new BitmapToBlackAndWhiteConverter(image.Bitmap); int suwak = Form1.trackbar * (eg.Emiters.Count / 10); if (Form1.trackbar != 10) { eg.Emiters.RemoveRange(suwak, (eg.Emiters.Count - suwak) - 1); } averageTable = new double[eg.Emiters.ToArray().Length, n + 1]; double maxAverage = double.MinValue; double minAverage = double.MaxValue; int emiterIndex = 0; eg.Emiters.ForEach(e => { IDetectorsGenerator dg = CreateDetectorGenerator(useKeyPoints, n, l, circle, e, radius); EmiterDetectorsSystem newSystem = new EmiterDetectorsSystem(e, dg.Detectors); systems.Add(newSystem); int detectorIndex = 0; newSystem.Detectors.ForEach(detector => { LineCreator lc = new LineCreator(e.Point, detector.Point); LineSummer summer = new LineSummer(lc.Line, blackBitmap.ConvertedTab); if (!Form1.checkBoxState) { lc.Line.ForEach(pointOnLine => { OutPutImage.SumOfAverageTable[pointOnLine.X, pointOnLine.Y] += summer.Average; OutPutImage.CountOfAverageTable[pointOnLine.X, pointOnLine.Y] += 1; }); } averageTable[emiterIndex, detectorIndex++] = summer.Average; if (summer.Average > maxAverage) { maxAverage = summer.Average; } if (summer.Average < minAverage) { minAverage = summer.Average; } }); emiterIndex++; }); if (Form1.checkBoxState) { //OutPutImage zakomentowałem, żeby najpierw przefiltrować tablice avarageTable int aaa = eg.Emiters.ToArray().Length; int bbb = n + 1; sinogramFiltered = new double[aaa, bbb]; for (int i = 0; i < aaa; i++) { for (int j = 0; j < bbb; j++) { for (int k = 0; k < bbb; k++) { sinogramFiltered[i, j] += fx(j, k) * averageTable[i, k]; } } } //dalej to dla tych samych emiterów, dodaje przefiltrowaną wartość emiterIndex = 0; eg.Emiters.ForEach(e => { IDetectorsGenerator dg = CreateDetectorGenerator(useKeyPoints, n, l, circle, e, radius); EmiterDetectorsSystem newSystem = new EmiterDetectorsSystem(e, dg.Detectors); //systems.Add(newSystem); int detectorIndex = 0; newSystem.Detectors.ForEach(detector => { LineCreator lc = new LineCreator(e.Point, detector.Point); LineSummer summer = new LineSummer(lc.Line, blackBitmap.ConvertedTab); lc.Line.ForEach(pointOnLine => { OutPutImage.SumOfAverageTable[pointOnLine.X, pointOnLine.Y] += sinogramFiltered[emiterIndex, detectorIndex]; OutPutImage.CountOfAverageTable[pointOnLine.X, pointOnLine.Y] += 1; }); detectorIndex++; }); emiterIndex++; }); } NormalizeTab(eg.Emiters.ToArray().Length, n + 1, maxAverage, averageTable, minAverage); GenerateBitmap(eg.Emiters.ToArray().Length, n + 1, averageTable); Console.Write("DoRandonTransform --> DONE\n"); }