Beispiel #1
0
 private void rotLL_Click(object sender, EventArgs e)
 {
     rotArduino.turnLeft(1000);
 }
Beispiel #2
0
        private void RotateEvent(object sender, EventArgs e)
        {
            rotTimer.Stop();
            //
            //Console.WriteLine("rotate");

            if (++currentLine < numLinesPerScan)
            {
                rotArduino.turnLeft(stepsPerRot);
                Console.WriteLine("currentLine: " + currentLine);
                linTimer.Start();
            }
            else
            {
                int   maxValue = scanData.Max(); //80;
                float value;
                Color color;
                Console.WriteLine("maxValue: " + scanData.Max().ToString());

                int x;
                int y;

                for (int i = 0; i < 500; i++)
                {
                    //scanData.Add(10);
                }


                Console.WriteLine("total points: " + scanData.Count);

                for (int i = 0; i < scanData.Count; i++)
                {
                    x     = i / numSamplesPerLine;
                    value = scanData[i];

                    if (x % 2 != 0)
                    {
                        y = i % numSamplesPerLine;
                    }
                    else
                    {
                        y = (numSamplesPerLine - 1) - (i % numSamplesPerLine);
                    }


                    //Console.WriteLine("x: " + x + " y: " + y);


                    value = 255 - (value / maxValue * 255);
                    color = Color.FromArgb(Convert.ToInt32(value), Convert.ToInt32(value), Convert.ToInt32(value));

                    try
                    {
                        sinogram.SetPixel(x, y, color);
                    }
                    catch (Exception ex)
                    {
                    }
                }

                /*
                 * for (int x = 0; x < sinogram.Width; x++)
                 * {
                 *  for (int y = 0; y < sinogram.Height; y++)
                 *  {
                 *      //Console.WriteLine("x: " + x + " y: " + y);
                 *      if (toTheLeftToTheLeft)
                 *      {
                 *          //Console.WriteLine(x * numLinesPerScan + y);
                 *          value = scanData[x * numLinesPerScan + y];
                 *      }
                 *      else
                 *      {
                 *          //Console.WriteLine(x * numLinesPerScan + numSamplesPerLine - 1 - y);
                 *          value = scanData[x * numLinesPerScan + numSamplesPerLine - 1 - y];
                 *      }
                 *
                 *      value = 255 - (value / maxValue * 255);
                 *      color = Color.FromArgb(Convert.ToInt32(value), Convert.ToInt32(value), Convert.ToInt32(value));
                 *      sinogram.SetPixel(x, y, color);
                 *  }
                 *
                 *  toTheLeftToTheLeft = !toTheLeftToTheLeft;
                 * }
                 */
                sinogram.Save("sinogram" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg", ImageFormat.Jpeg);
                Console.WriteLine("scan done");
                linTimer.Stop();

                // scandata verwerken enzo
                ScanDone = true;
            }
        }