public EmguCv(string file) { FitFiles = new FitsFile(file); MethodTranfrom Method = new MethodTranfrom(FitFiles.GenerateImage()); this.fomula = new MethodStaticFomula(); this.jpg = Genarate2Jpg(Method.GetRaw()); // Create JPGE //this.raw = this.raw8bit.Mat.ToImage<Bgr, byte>(); //this.raw8bit = Method.Convert1628(); // Create Raw }
/// <summary>Attempts to retrieve the image from the reference.</summary> public bool TryGetImage(out FitsImage Image) { if (!Readers.ContainsKey(ReaderType)) { Image = null; return(false); } try { FitsFile ff = Readers[ReaderType](Path); Image = new FitsImage(ff, Number, SkipWCS); return(true); } catch { Image = null; return(false); } }
private Image <Bgr, byte> Genarate2Jpg(Matrix <ushort> image) { /* * Createed by pee chaimg */ ushort LowerValue, UpperValue; double LowerPercen, UpperPercen; FitsFile.GetStrecthProfile(out LowerPercen, out UpperPercen); FitsFile.GetUpperAndLowerShortBit(image, out LowerValue, out UpperValue, LowerPercen, UpperPercen); Matrix <ushort> imgJPG = FitsFile.StretchImageU16Bit(image, LowerValue, UpperValue); //Mat imgJPG = CvInvoke.Imread(namefile); return(imgJPG.Mat.ToImage <Bgr, byte>()); }
public static void WriteFits(DataSet dataSet, Stream stream) { FitsFile fits = new FitsFile(stream, FitsFileMode.Write); fits.IsBufferingAllowed = true; // Primary header var prim = SimpleHdu.Create(fits, true, true, true); prim.WriteHeader(); // Table BinaryTableHdu tab = BinaryTableHdu.Create(fits, true); // add special mapping tansforming decimal into string: tab.RegisterTypeMapping(new DecimalTypeMapping()); using (DataTableReader reader = dataSet.CreateDataReader()) { tab.WriteFromDataReaderAsync(reader); } fits.Close(); stream.Close(); }
private void StackButton_Click(object sender, EventArgs e) { FitsPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; const double defaultRAHours = 0; const double defaultDecDegrees = 0; StackButton.BackColor = Color.Salmon; openFileDialog1.Filter = "FITS files (*.fit)|*.fit"; openFileDialog1.ShowDialog(); string[] fileNames = openFileDialog1.FileNames; if (fileNames.Length < 1) { return; } fitsFileTextBox.Text = fileNames[0]; FitsFile[] fsSet = new FitsFile[fileNames.Length]; for (int fs = 0; fs < fileNames.Length; fs++) { fsSet[fs] = new AstroImage.FitsFile(fileNames[fs], true); } // //Stack fsSet int pCount; if (SequentialBox.Checked) { pCount = 0; } else { pCount = fsSet.Length - 1; } for (int i = pCount; i < fsSet.Length; i++) { FitsFile af = Stack.StraightStack(fsSet, i); double pixSize = 1; if (af.FocalLength != 0) { pixSize = (206.265 / af.FocalLength) * af.XpixSz; } if (af.RA == 0) { af.RA = defaultRAHours; } if (af.Dec == 0) { af.Dec = defaultDecDegrees; } ap = new AstroPic(af); //target cross hairs //Point target; //target = af.RADECtoImageXY(af.RA, af.Dec); //target.X -= 40; //target.Y += 2; //ap.AddCrossHair(target, 80, 2); //Size subSize = new Size(ap.PixImage.Width / 1, ap.PixImage.Height / 1); //Image subImage = af.FitsSubframe(ap.PixImage, target, subSize); //Size sizeUp = new Size(ap.PixImage.Size.Width / 2, ap.PixImage.Size.Height / 2); //Image baseImage = AstroPic.Zoom(ap.PixImage, sizeUp); Image baseImage = ap.ResizeImage(FitsPictureBox.Size, true); FitsPictureBox.Image = baseImage; //System.Threading.Thread.Sleep(1000); Show(); Application.DoEvents(); } StackButton.BackColor = Color.Green; return; }
private void LoadButton_Click(object sender, EventArgs e) { const double defaultRAHours = 0; const double defaultDecDegrees = 0; LoadFItsButton.BackColor = Color.Salmon; openFileDialog1.Filter = "FITS files (*.fit)|*.fit"; openFileDialog1.ShowDialog(); fitsFileTextBox.Text = openFileDialog1.FileName; af = new AstroImage.FitsFile(fitsFileTextBox.Text, true); //monochrome test //Bitmap monoBMP = MonoImage.MakeMonochromeBitmap (af.fitsArray , 255); //fitsPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; //fitsPictureBox.Image = monoBMP; //return; double pixSize = 1; if (af.FocalLength != 0) { pixSize = (206.265 / af.FocalLength) * af.XpixSz; } if (af.RA == 0) { af.RA = defaultRAHours; } if (af.Dec == 0) { af.Dec = defaultDecDegrees; } ap = new AstroPic(af); Point target; target = af.RADECtoImageXY(af.RA, af.Dec); //target = af.RADECtoImageXY(2.6733599, 39.06333); //NGC 1023 J2000 (Lorenzo) //target = af.RADECtoImageXY(2.673519167, 39.06290278); //0.31 center J2000 //target = af.RADECtoImageXY(2.6733611, 39.06333);// NGC 1023 center J2000 //target = af.RADECtoImageXY(2.6723948953, 39.03134476); //Tycho something, near NGC 1023 //target = af.RADECtoImageXY(2.6733599,39.06333); /NGC 1023 //target = af.RADECtoImageXY(2.6942859,39.14737); target.X -= 40; target.Y += 2; ap.AddCrossHair(target, 80, 2); Size subSize = new Size(ap.PixImage.Width / 4, ap.PixImage.Height / 4); //Image subImage = af.FitsSubframe(ap.PixImage, target, subSize); //Size sizeUp = new Size(ap.PixImage.Size.Width / 2, ap.PixImage.Size.Height / 2); //Image baseImage = AstroPic.Zoom(ap.PixImage, sizeUp); Image baseImage = ap.PixImage; FitsPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; FitsPictureBox.Image = baseImage; LoadFItsButton.BackColor = Color.Green; return; }