Example #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Bitmap RawIMG;

            ImageDataProcessor imgp = new ImageDataProcessor();


            Int32[,] _imagearray = imgp.ReadRaw("C:\\temp\\IMG_2s_100iso_0C_2020-06-14--01-01-33.NEF");

            var buffer = new byte[_imagearray.GetLength(0) * _imagearray.GetLength(1) * System.Runtime.InteropServices.Marshal.SizeOf(typeof(Int16))];

            Buffer.BlockCopy(_imagearray, 0, buffer, 0, buffer.Length);

            var flatarray = FlipAndConvert2d(_imagearray);


            byte[] flatarraybyte = new byte[flatarray.Length * 2];
            Buffer.BlockCopy(flatarray, 0, flatarraybyte, 0, flatarray.Length * 2);



            RawIMG = Contrast(ColorBalance(createImage(_imagearray), 50, 50, 50), 15);



            RawIMG.Save("C:\\temp\\test.png");

            pictTestfrm.Image = RawIMG;
        }
Example #2
0
        private void PrepareCameraImageArray(string rawFileName)
        {
            if (CameraSettings.CameraMode == Enums.CameraMode.Color16)
            {
                cameraImageArray = _imageDataProcessor.ReadAndDebayerRaw(rawFileName);
            }
            else if (CameraSettings.CameraMode == Enums.CameraMode.ColorJpg)
            {
                cameraImageArray = _imageDataProcessor.ReadJpeg(rawFileName);
            }
            else if (CameraSettings.CameraMode == Enums.CameraMode.RGGB)
            {
                cameraImageArray = _imageDataProcessor.ReadRaw(rawFileName);
            }

            cameraImageArray = _imageDataProcessor.CutArray(cameraImageArray, StartX, StartY, NumX, NumY, CameraXSize, CameraYSize);
        }
Example #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Bitmap RawIMG;

            ImageDataProcessor imgp = new ImageDataProcessor();

            //Bitmap Test = new Bitmap("C:\\temp\\allskynikon.jpg");

            Int32[,] _imagearray = imgp.ReadRaw("C:\\temp\\canon2.CR2");

            //RawIMG = Contrast(ColorBalance(createImage(_imagearray), 50, 50, 50), 15);
            //RawIMG = createImage(_imagearray);

            RawIMG = createImage(_imagearray);

            RawIMG.Save("C:\\temp\\test.png");

            pictTestfrm.Image = RawIMG;
        }
Example #4
0
        static void Main()
        {
            ExecuteCommand("--status --debug --timeout 3");

            var d = ParseStatus(File.ReadAllText(@"c:\git-vtorkalo\ASCOM.DSLR\testdata\status.txt"));



            var p = new ImageDataProcessor();

            var detector = new CameraModelDetector(p);

            var data0 = p.ReadRaw(@"d:\ascomdev\git\ASCOM.DSLR\testdata\test.dng-0000.dng");



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Example #5
0
        static void Main(string[] args)
        {
            var cameraModels = JsonConvert.DeserializeObject <CameraModel[]>(File.ReadAllText("cameramodels.json"));

            SonyCamera camera = new SonyCamera(cameraModels.First(m => m.ID == "SLTA99"), ImageFormat.CFA, false);

            camera.ExposureReady     += Camera_ExposureReady;
            camera.ExposureCompleted += Camera_ExposureCompleted;

            Console.WriteLine("Press S to take exposure.\nPress R to read ARW file and save to grayscale TIFF.\nPress D to read ARW file and save to color TIFF.\nPress J to read JPEG file and save to color TIFF.\nPress E to exit program.");
            do
            {
                var key = Console.ReadKey(true);
                if (key.Key == ConsoleKey.S)
                {
                    if (camera.IsConnected() == false)
                    {
                        camera.Connect();
                    }
                    camera.StartExposure(400, 3, true);
                }
                else if (key.Key == ConsoleKey.R)
                {
                    ImageDataProcessor dataProcessor = new ImageDataProcessor();

                    Console.Write("Reading RAW file to array ...");
                    uint[,] array = dataProcessor.ReadRaw("D:\\astrophoto\\test\\test.ARW");
                    Console.WriteLine(" Done.");

                    Console.WriteLine($"Array length: {array.LongLength*4} bytes");

                    WriteImageStatistics(dataProcessor, array);

                    Console.Write("Saving to tiff...");
                    SaveToGrayscaleTiff("D:\\astrophoto\\test\\grayscale.tiff", array);
                    Console.WriteLine(" Done.");
                }
                else if (key.Key == ConsoleKey.D)
                {
                    ImageDataProcessor dataProcessor = new ImageDataProcessor();

                    Console.Write("Reading RAW file and debayer to array ...");
                    uint[,,] array = dataProcessor.ReadAndDebayerRaw("D:\\astrophoto\\test\\test.ARW");
                    Console.WriteLine(" Done.");

                    Console.WriteLine($"Array length: {array.LongLength*4} bytes");

                    WriteImageStatistics(dataProcessor, array);

                    Console.Write("Saving to tiff...");
                    SaveToColorTiff("D:\\astrophoto\\test\\color.tiff", array);
                    Console.WriteLine(" Done.");
                }
                else if (key.Key == ConsoleKey.J)
                {
                    ImageDataProcessor dataProcessor = new ImageDataProcessor();

                    Console.Write("Reading JPEG file array ...");
                    uint[,,] array = dataProcessor.ReadJpeg("D:\\astrophoto\\test\\test.JPG");
                    Console.WriteLine(" Done.");

                    Console.WriteLine($"Array length: {array.LongLength} bytes");

                    WriteImageStatistics(dataProcessor, array);

                    Console.Write("Saving to tiff...");

                    SaveToColor8bitTiff("D:\\astrophoto\\test\\jpeg.tiff", array);


                    Console.WriteLine(" Done.");
                }
                else if (key.Key == ConsoleKey.A)
                {
                    Console.Write("Writing camera models to json...");
                    //serialize CameraModel to JSON

                    CameraModel.Models = new CameraModel[]
                    {
                        _sltA99
                    };

                    string json = JsonConvert.SerializeObject(CameraModel.Models);
                    File.WriteAllText("test.json", json);
                    Console.WriteLine(" Done.");

                    Console.Write("Writing camera models from json...");
                    var models = JsonConvert.DeserializeObject <CameraModel[]>(File.ReadAllText("test.json"));
                    Console.WriteLine($" Done. Read {models.Length} models.");
                }
                else if (key.Key == ConsoleKey.E)
                {
                    break;
                }
            } while (true);
        }