I am making gamma-spectrometer from webcam. Its matrix covered in foil and image its getting completely dark, but sometimes cosmic/gamma rays or another particle hits matrix and creates a white dot, this dots brightness is indicator of particle energy. My program need to collect these dots brightness into array/list. My current solution is using AForge. Its scanning every pixel of the image and finding all white dots, but this takes a lot of time and I am skipping a lot of frames just because scanning of older once is not finished. Using .Net Core 3.1
My Current code:
private void Scan(Bitmap map)
{
Rectangle rect = new Rectangle(0, 0, map.Width, map.Height);
BitmapData bmpData = map.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
IntPtr ptr = bmpData.Scan0;
int bytes = bmpData.Stride * map.Height;
byte[] rgbValues = new byte[bytes];
Marshal.Copy(ptr, rgbValues, 0, bytes);
int stride = bmpData.Stride;
for (int column = 0; column < bmpData.Height; column++)
{
for (int row = 0; row < bmpData.Width; row++)
{
Color pixel = Color.FromArgb(rgbValues[(column * stride) + (row * 3)], rgbValues[(column * stride) + (row * 3) + 1], rgbValues[(column * stride) + (row * 3) + 2]);
if (pixel.GetBrightness() > 0.2) Dots.Add(pixel);
}
}
}