PetteriAimonen / focus-stack

Fast and easy focus stacking
MIT License
293 stars 43 forks source link

Feature request: Slabbing stacks #49

Closed CorBer closed 2 months ago

CorBer commented 3 months ago

Hi

I just discovered your focus-stacking code and the quality of the alignment/stacking looks really good. But I do have issues on my machine (Linux). It seems that it can easily run out of memory (at least it seems like that) .. last section of the verbose output (stacking 30 image)

P6230828.JPG has resolution 5184x3888, using 10 wavelet levels and expanding to 6144x4096
77.721           T0 Finished task 73 in 0.252 s.
77.721 [ 74/162] T0 Starting task: Grayscale images/P6230828.JPG
77.769           T0 Finished task 74 in 0.048 s.
77.769 [ 75/162] T0 Starting task: Align P6230828.JPG to P6230827.JPG
aligned_P6230828.JPG transform: [1.040 0.021 -153.086; -0.011 1.009 36.304]
aligned_P6230828.JPG contrast map: C:0.989, X:0.010, X2:0.007, Y:0.006, Y2:-0.017
aligned_P6230828.JPG whitebalance: R:x0.951+2.6, G:x0.981+2.5, B:x0.964+1.8
aligned_P6230828.JPG transformed corners TL (348.1,136.0), TR (5738.0,79.3), BL (428.0,4059.2), BR (5817.8,4002.5)
aligned_P6230828.JPG valid area X 480, Y 136, W 5184, H 3856
79.753           T0 Finished task 75 in 1.984 s.
79.753 [ 76/162] T0 Starting task: Grayscale aligned_P6230828.JPG
79.778           T0 Finished task 76 in 0.025 s.
79.778 [ 77/162] T0 Starting task: Forward-wavelet aligned_P6230828.JPG
Killed

I get around that by simply closing all software and only using thread=1.

My feature request is "slabbing", I havent seen that mentioned but it can be very handy for larger stacks. This is used for instance also in Zerene Stacker. You create multiple sub-stacks that use N frames and have M frames overlap between them. After this you can then join these sub-stacks into a final stack.

Thanks for working on this topic and producing working code !!

cheers Cor


waveSharp Free Image sharpen Software https://github.com/CorBer/waveSharp

TeensyBat Bat Detector https://github.com/CorBer/teensy_batdetector

RegiStax Free Image Processing Software http://www.astronomie.be/registax


PetteriAimonen commented 3 months ago

The already existing batching works mostly like that, except the color reassignment map is collected from all images.

Additional way to reduce memory use would be to divide the images to e.g. quarters after alignment, and process one section at a time.

Adding CXXFLAGS += -DUSE_MALLINFO will log the memory usage of the process at different points of the stacking. Unfortunately there isn't a portable way to get the amount of available memory, otherwise focus-stack could avoid starting new tasks until there is enough memory.

CorBer commented 3 months ago

Hi Peter,

But I do not get intermediate results stored. My topics for focus-stacking are alive and often dont keep position. When you process a stack in "substacks" and allow these results to be stored (preferably in 16bit PNG) these substacks can than be combined by the user but more selective. As stated your software seems to work great as it is now. I am setting up my programming environment (Lazarus) to build a simple GUI around your application. This way I hope to exploit substacks (will call the application multiple times with different sets of images) and create an "multi-image" editor as Zerene allows.

Thanks for the fast answer, I will check what CXXflags reports. EDIT: CXXFLAGS need to be added when compiling the software it seems (Ive never worked in C++ in this way so sorry for the lack of knowledge). Currently I will just prevent this from happening by using substacks. cheers Cor

CorBer commented 3 months ago

My initial GUI is work and I can create slabs (substacks) easily. But I have a question, is it possible to align all image first and then only stack so alignment is not needed again ? I have tried align-only but that only creates a set of images that are aligned. This would allow users to experiment with different stack settings easily as alignment does not have to be recalculated all the time.

CorBer commented 2 months ago

Hi,

From the lack of a further response its my guess that this option is not there. I will experiment further.

cheers Cor