Jusas / WatneyAstrometry

Astrometric solver library and app for .NET Core
Apache License 2.0
31 stars 0 forks source link

Return x,y position of each star in a quad. #1

Closed swaterfall closed 1 year ago

swaterfall commented 3 years ago

Would it be possible to have a function that returns the x,y position of each star in a quad that can be then used to produce an image like the one below shown on the ASTAP page:

Jusas commented 3 years ago

Yes, actually the feature kind of already exists but is not exposed outside the library and is not included in the CLI app outputs. Drawing the quads itself would need to be implemented into the CLI solver, but is basically not a big deal as visual tests have already been coded into the unit tests.

I suppose the quad and star positions could be written into a diagnostics file with quite little effort. I can see more usefulness in drawing the quads as a diagnostics tool, but it's not a big deal to implement both things. I'll put this on my list.

Jusas commented 1 year ago

Just realized this was still open 😅

This feature is available on the Watney Desktop, as well as possible to get and use for your own visualizations in the WatneyAstrometry.Core library via the SolveResult.GetDiagnosticsData() method. You can see this done in the sources, https://github.com/Jusas/WatneyAstrometry/blob/master/src/WatneyAstrometry.SolverVizTools/Drawing/Visualizer.cs

var solveResult = await solver.SolveFieldAsync(img, strategy, options, token);
var diagData = solveResult.GetDiagnosticsData();

// diagData.DetectedStars
// diagData.MatchInstances
// many things available...

var quads = solveResult.GetDiagnosticsData().FormedImageStarQuads;

foreach (var quad in quads)
{
    // With image quads we can draw lines between stars, and also a shape
    // representing the ratios.

    var points = new List<PointF>();
    foreach (var star in quad.ImageStars)
    {
        points.Add(new PointF((float)star.X, (float)star.Y));
    }

    var font = GetDefaultFont(GetQuadSymbolFontSize(solveResult));

    points.Add(new PointF(points.First().X, points.First().Y));
    var color = GenerateQuadColor((double)points.First().X, (double)points.First().Y);

    baseImage.Mutate(context =>
    {
        context.DrawLines(_defaultDrawingOptions, color, 1.0f, points.ToArray());
    });
}

image

As for the CLI app, I currently don't have big plans for visualizations. I'm closing this issue as in a sense this feature now exists, along with an example of how this could be achieved.

But there's no real reason why it couldn't be there in the CLI app as well but since it's not a priority for me, I'm just going to say that pull requests are welcome 🚀 🙂