Example #1
0
        public PlateConstStarPair AddStar(ImagePixel plateStar, IStar celestialPyramidStarEntry, StarMapFeature feature)
        {
            double detectionCertainty = plateStar.SignalNoise;

            PlateConstStarPair starPair =
                AddStar(
                    plateStar.XDouble,
                    celestialPyramidStarEntry.RADeg,
                    plateStar.YDouble,
                    celestialPyramidStarEntry.DEDeg,
                    celestialPyramidStarEntry.Mag,
                    plateStar.Brightness,
                    detectionCertainty,
                    plateStar.IsSaturated);

#if ASTROMETRY_DEBUG
            Trace.Assert(m_Pairs.Find((pair) => pair.StarNo == celestialPyramidStarEntry.StarNo) == null);
#endif

            starPair.StarNo    = celestialPyramidStarEntry.StarNo;
            starPair.FeatureId = feature != null ? feature.FeatureId : -1;
            starPair.RADeg     = celestialPyramidStarEntry.RADeg;
            starPair.DEDeg     = celestialPyramidStarEntry.DEDeg;

            return(starPair);
        }
Example #2
0
        private PlateConstStarPair AddStar(double x, double RADeg, double y, double DE, double mag, int intensity, double detectionCertainty, bool isSaturated)
        {
            double xExpected, yExpected;

            TangentPlane.CelestialToTangent(RADeg, DE, m_Tangent_RA0, m_Tangent_DE0, out xExpected, out yExpected);

            PlateConstStarPair pair = new PlateConstStarPair();

            pair.x                  = x;
            pair.y                  = y;
            pair.ExpectedXTang      = xExpected;
            pair.ExpectedYTang      = yExpected;
            pair.Mag                = mag;
            pair.Intensity          = (uint)intensity;
            pair.IsSaturated        = isSaturated;
            pair.DetectionCertainty = detectionCertainty;

            m_Pairs.Add(pair);

            return(pair);
        }
Example #3
0
        private PlateConstStarPair AddStar(double x, double RADeg, double y, double DE, double mag, int intensity, double detectionCertainty, bool isSaturated)
        {
            double xExpected, yExpected;
            TangentPlane.CelestialToTangent(RADeg, DE, m_Tangent_RA0, m_Tangent_DE0, out xExpected, out yExpected);

            PlateConstStarPair pair = new PlateConstStarPair();
            pair.x = x;
            pair.y = y;
            pair.ExpectedXTang = xExpected;
            pair.ExpectedYTang = yExpected;
            pair.Mag = mag;
            pair.Intensity = (uint)intensity;
            pair.IsSaturated = isSaturated;
            pair.DetectionCertainty = detectionCertainty;

            m_Pairs.Add(pair);

            return pair;
        }
        public override void MouseMove(Point location)
        {
            IStarMap map = AstrometryContext.Current.StarMap;
            if (map == null) return;

            bool nearbyStarFound = false;

            AstrometricState state = AstrometryContext.Current.AstrometricState;
            if (state != null)
            {
                if (state.AstrometricFit != null)
                {
                    for (int radius = 1; radius < 8; radius++)
                    {
                        ImagePixel centroid = map.GetCentroid(location.X, location.Y, radius);
                        if (centroid == null) continue;

                        foreach (PlateConstStarPair star in state.AstrometricFit.FitInfo.AllStarPairs)
                        {
                            if (Math.Abs(star.x - centroid.XDouble) < radius &&
                                Math.Abs(star.y - centroid.YDouble) < radius)
                            {
                                m_Object = star;

                                nearbyStarFound = true;
                                break;
                            }
                        }

                        if (nearbyStarFound) break;
                    }

                    if (!nearbyStarFound)
                    {
                        m_State = SelectObjectState.NoObject;
                    }
                    else
                        m_State = SelectObjectState.ObjectLocked;

                    if (m_AstrometricState.MeasuringState == AstrometryInFramesState.Ready)
                    {
                        double ra, de;
                        state.AstrometricFit.GetRADEFromImageCoords(location.X, location.Y, out ra, out de);

                        string moreInfo = string.Format("RA={0} DE={1}", AstroConvert.ToStringValue(ra / 15, "HHhMMmSS.Ts"), AstroConvert.ToStringValue(de, "+DD°MM'SS\""));
                        m_VideoController.DisplayCursorPositionDetails(location, moreInfo);
                    }
                }
                else
                {
                    StarMapFeature nearbyFeature = map.GetFeatureInRadius(location.X, location.Y, 8);
                    nearbyStarFound = nearbyFeature != null && nearbyFeature.PixelCount > 4;
                }

                m_VideoController.SetPictureBoxCursor(nearbyStarFound ? Cursors.Hand : (state.ManualStarIdentificationMode ? Cursors.Cross : Cursors.Default));
            }
        }
Example #5
0
        internal void SelectStar(PlateConstStarPair selectedPair, PSFFit psfFit)
        {
            if (selectedPair != null)
            {
                lblStarNo.Text = selectedPair.StarNo.ToString();
                lblRA.Text = AstroConvert.ToStringValue(selectedPair.RADeg / 15.0, "HH MM SS.TT");
                lblDE.Text = AstroConvert.ToStringValue(selectedPair.DEDeg, "+DD MM SS.T");
                lblX.Text = selectedPair.x.ToString("0.00");
                lblY.Text = selectedPair.y.ToString("0.00");
                lblResRA.Text = string.Format("{0}\"", selectedPair.FitInfo.ResidualRAArcSec.ToString("0.00"));
                lblResDE.Text = string.Format("{0}\"", selectedPair.FitInfo.ResidualDEArcSec.ToString("0.00"));

                m_SelectedPSF = psfFit;
            }
            else
            {
                m_SelectedPSF = null;
            }

            pnlSelectedStar.Visible = selectedPair != null;
        }
Example #6
0
        // TODO: Use the imeplementation in the MainForm instead
        private void DrawHighResFeature(ImagePixel pixel, PlateConstStarPair selectedPair, LeastSquareFittedAstrometry astrometry)
        {
            int x0 = pixel.X;
            int y0 = pixel.Y;
            if (x0 < 15) x0 = 15; if (y0 < 15) y0 = 15;
            if (x0 > AstrometryContext.Current.FullFrame.Width - 15) x0 = AstrometryContext.Current.FullFrame.Width - 15;
            if (y0 > AstrometryContext.Current.FullFrame.Height - 15) y0 = AstrometryContext.Current.FullFrame.Height - 15;

            int bytes;
            int bytesPerPixel;
            int selIdx;

            Bitmap featureBitmap = new Bitmap(31 * 8, 31 * 8, PixelFormat.Format24bppRgb);
            m_VideoController.UpdateZoomedImage(featureBitmap, pixel);

            BitmapData zoomedData = featureBitmap.LockBits(new Rectangle(0, 0, 31 * 8, 31 * 8), ImageLockMode.ReadWrite, featureBitmap.PixelFormat);
            try
            {
                bytes = zoomedData.Stride * featureBitmap.Height;
                byte[] zoomedValues = new byte[bytes];

                Marshal.Copy(zoomedData.Scan0, zoomedValues, 0, bytes);

                bytesPerPixel = AstrometryContext.Current.BytesPerPixel;

                byte saturatedR = TangraConfig.Settings.Color.Saturation.R;
                byte saturatedG = TangraConfig.Settings.Color.Saturation.G;
                byte saturatedB = TangraConfig.Settings.Color.Saturation.B;

                selIdx = 0;
                for (int y = 0; y < 31; y++)
                    for (int x = 0; x < 31; x++)
                    {
                        for (int i = 0; i < 8; i++)
                            for (int j = 0; j < 8; j++)
                            {
                                int zoomedX = 8 * x + i;
                                int zoomedY = 8 * y + j;

                                int zoomedIdx = zoomedData.Stride * zoomedY + zoomedX * bytesPerPixel;

                                if (zoomedValues[zoomedIdx] > TangraConfig.Settings.Photometry.Saturation.Saturation8Bit)
                                {
                                    // Saturation detected
                                    zoomedValues[zoomedIdx] = saturatedR;
                                    zoomedValues[zoomedIdx + 1] = saturatedG;
                                    zoomedValues[zoomedIdx + 2] = saturatedB;
                                }
                            }

                        selIdx++;
                    }

                Marshal.Copy(zoomedValues, 0, zoomedData.Scan0, bytes);
            }
            finally
            {
                featureBitmap.UnlockBits(zoomedData);
            }

            Pen starPen = catalogStarPen;

            double xFitUnscaled = pixel.XDouble;
            double yFitUnscaled = pixel.YDouble;

            if (selectedPair != null && selectedPair.FitInfo.UsedInSolution)
            {
                starPen = referenceStarPen;
                astrometry.GetImageCoordsFromRADE(selectedPair.RADeg, selectedPair.DEDeg, out xFitUnscaled, out yFitUnscaled);
            }
            else if (selectedPair != null && selectedPair.FitInfo.ExcludedForHighResidual)
            {
                starPen = rejectedStarPen;
                astrometry.GetImageCoordsFromRADE(selectedPair.RADeg, selectedPair.DEDeg, out xFitUnscaled, out yFitUnscaled);
            }
            else
            {
                starPen = unrecognizedStarPen;
            }

            double xFit = (8 * (xFitUnscaled - x0 + 16)) - 4;
            double yFit = (8 * (yFitUnscaled - y0 + 16)) - 4;
        }