PetteriAimonen / focus-stack

Fast and easy focus stacking
MIT License
249 stars 37 forks source link

--align-only with --global-align / Question: Get crop rectangle from verbose-output #21

Open LGimmick opened 2 years ago

LGimmick commented 2 years ago

Hi,

if I add both parameters "--align-only" and "--global-align" it only loads the first two images (used *.jpg) and then exits. Without --global-align it works fine. Version: Latest.

And my question: -- verbose outputs something like "transformed with corners TL (,), TR (,), BL (,), BR (,)" per image. I guess that describes the boundary-corners of each image after the alignment inside the "expanded image". So to crop the overlapping part of each aligned-image (like the result image) I have to get the min/max x/y coordinates of each rectangle and crop every aligned-image with the same rectangle. Is that correct? :)

PetteriAimonen commented 2 years ago

The error with --global-align --align-only should be fixed now.

And yeah, that is correct interpretation of the corners. I added verbose log message with aligned_pcb_001.jpg valid area X 19, Y 26, W 2005, H 1503 that hopefully makes it a bit easier. The total area that is valid for all images is currently only calculated during merging, so I cannot directly log that.

Btw, it might make sense to specify some stable format for these messages that are used for machine parsing. Emitting them to the log is easy and simple, but perhaps something like this would be easier to parse:

 1.779           T3 Finished task 25 in 0.039 s.
 1.779           Memory use: 49.557 MB.
 .. more normal log messages ...
 JSON_DATA: {"task": "Task_Align", "input": "pcb_001.jpg", "output": "aligned_pcb_001.jpg", "corners": {"tl": [17.9,25.2] ... }, "valid_area": {"x": 19, "y": 26, ...}}
LGimmick commented 2 years ago

The format suggestion sounds good!

The newest build (atleast for Win?) does not seem to include the newest code changes.

mviereck commented 1 year ago

Yet I wrote a small script to crop the aligned images (needs ImageMagick): https://github.com/mviereck/microscopy-tools/blob/master/stackalign

Though, it would make sense if focus-stack could do this itself.

mcranium commented 4 months ago

I would also be interested to have focus-stack to have the option (or even as default) to crop the aligned images produced with the --align-only option. I often use enfuse for merging normal map focus stacks (less artefacts) and this would allow me to easily integrate it into my scripts.