melix / astro4j

Astronomy libraries for Java
Apache License 2.0
27 stars 4 forks source link

Feature Request: manual hints for line tracing (when it would otherwise fail) #347

Closed vnp85 closed 1 month ago

vnp85 commented 1 month ago

Problem: Perhaps due to the high activity of the Sun with calcium plages all over the place, which affect the average image, the line detection fails. INTI also fails with today's Sun, but it had one successful-ish detection too.

Tested with: 2.5.0 and 2.6.0

Feature request: it would be awesome to be able to manually add markers, hints. Placing markers with the mouse, onto the spectral line, where one is sure that it is the middle of the line. Thus aid the creation of the polynomial.

For example, in a calcium plage, there is the dark line in the very middle of the bright area inside the spectral line. These manually placed markers should aid the line detection. The video analyzer (aka spectrum debugger) is the UI element I hoped to find this in.

image

image

vnp85 commented 1 month ago

Ideally, one would put markers like these:

image

vnp85 commented 1 month ago

A less user friendly idea would be to place a JSON file next to the ser video, in which the user manually declares these markers' coordinates. If no JSON file, then no hints, process it as usual.

The way these coordinates are obtained is up to the user... my workflow is opening the ser in AS4, either printscreen it or save individual frames of interest (or PIPP or something) and then measure the pixels in say irfanview. This is how I memorized the pixel distances of interest, +25 for H epsilon, -250 from the D2 to the D3 line.

vnp85 commented 1 month ago

The little marked valley would be figure 7 here https://ned.ipac.caltech.edu/level5/Glossary/Jaschek/Ca.html

vnp85 commented 1 month ago

2.6.1 went "off" with the line detection

image

vnp85 commented 1 month ago

This is the detection I have. I could post the ser video, same narnia server (a brave little raspberry pi), 10 GiB give or take.

image

vnp85 commented 1 month ago

These particular plages most certainly don't help the detection

image

vnp85 commented 1 month ago

Sadly, the issue repeated with today's Calcium H also, this time dev version 2.6.1

vnp85 commented 1 month ago

One of today's average images:

image

`12:56:19.140 [INFO] Output directory set to G:\2024-07-11\Sun-CaH_filter-n0 12:56:19.151 [INFO] File 2024-07-11-0902_3-Sun-CaH.ser 12:58:25.917 [INFO] Dimensions of raw image determined : 3696x7834 12:58:25.917 [INFO] Processing will require approximatively 2.43GB of disk space 12:58:26.098 [INFO] Detected spectral line Calcium (K) with binning 2 (for pixel size 2.00µm) 12:58:26.098 [INFO] Starting reconstruction... 12:58:26.098 [INFO] Distortion polynomial ax3 + bx2 + cx + d = 0

melix commented 1 month ago

Yeah as you noted, the white spots in the calcium lines are messing up with detection. I need to figure out how to integrate a manual mode, that shouldn't be too complicated, it's more of a usability issue.

vnp85 commented 1 month ago

For no-UI, my suggestion would be to look for an optional json when loading the ser video. Same name, different extension.

That JSON could contain a keyname with a value that's an array of points that should be used to find the polynomial. Either globally, entirely ignoring the auto-detection step, or regionally, ignoring the detection for a column width around each point, but doing the detection as before when nothing is defined for the given region.

In a way this fits your ImageMath philosophy, easy buttons for default use cases, and scripts for complex ones.

Last time I wrote Java was in Uni, and that was around Java 6-8... let this be my excuse for now :)

melix commented 1 month ago

I have implemented it, but not using configuration file: using the video analyzer. You can find docs in #350. Would be great if you could test the dev version (you will have to uninstall any previous dev version you had before). Once you confirm it works for you I will perform a new release, thanks!

vnp85 commented 1 month ago

Thank you, let me load it.

vnp85 commented 1 month ago

I can see the commit message, but the link I see in the dev version is still 2.6.1. Is the update live somewhere?

melix commented 1 month ago

Yes, dev versions are overwritten on each commit

vnp85 commented 1 month ago

After manually selecting and getting a polynomial that did straighten up the image, the autodetection ran and gave the average with the same weird red line, but the log on the right indicates the right coefficients. And the reconstructed image did look awesome, let me see the final one... :D

vnp85 commented 1 month ago

I got this, rather weird edges, but the disk is very good

image

vnp85 commented 1 month ago

The hydrogen epsilon also looks good and really as expected.

image

vnp85 commented 1 month ago

So good coefficients, but the avg image displayed is perhaps misleading, it shows the autodetected, not the forced polynomial. Maybe by design. It works well.

image

vnp85 commented 1 month ago

I may have misplaced the markers, hence the "polar caps", but overall it looks like it works pretty well. Thank you.

image

vnp85 commented 1 month ago

Before-after pair, it looks like it does the job.

image

vnp85 commented 1 month ago

I kept thinking about the polar caps: in the video analyzer, I think it would be great if one could zoom in, at least vertically, like 4x. Given how much a difference one pixel makes, and how disproportionate the raw is, 144x4000 for example, it would be nice to have a vertically exaggerated view, and not pin point the mouse.

melix commented 1 month ago

Yes, I agree that zooming would be good. Actually you can already zoom... but not move the spectrum when zoomed, which makes it pointless. I want to revamp the UI of the video analyzer, but I'm reaching limits of my UI skills :)

vnp85 commented 1 month ago

I think there is an option we have overlooked. Un-ticking the "lock polynomial" checkbox, we get to see curves frame by frame. Even if the average is toast, there are "happy frames" for which the detection looks very good. Currently (ver 2.6.1, release version) there is no option to use, or even copy-paste the polynomial of these happy-frames.

melix commented 1 month ago

That's a good improvement to have indeed. Let's create a separate issue for this.