PetteriAimonen / focus-stack

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

focus-stacking of focus-stacked images #46

Open ringmybell opened 3 months ago

ringmybell commented 3 months ago

Hello,

On a CM4 with 8gB ram there are only so many images I can merge before getting issues. For something like 24 images I need to limit the images to 2 and threads to 1. For 12 images I can get away with 4 images and 2 threads. I am still playing with these numbers to get the fastest and stable result.

I was wondering if it would be quicker, and achieve the same focus-stacked result, if I processed the 24 images in three batches of 8 images, and then merged the resulting 3 intermediate focus-stacked images into a single final focus-stacked image? Would that make any speed or image difference, will I get issues focus-stacking focus-stacked images?

I am assuming you are doing something like this on the fly in RAM, but it seems the RPI can't handle it so well. I wont be doing it enough for memory read / write to be an issue on the eMMC.

Thanks for providing the focus-stack software, it is very useful.

PetteriAimonen commented 3 months ago

It should provide quite similar result, especially if you use png format for the intermediate outputs, to avoid lossy compression.

I'm not sure what would explain the results you get, as the built-in batching should already limit the memory usage quite well. A log file with --verbose could be worth looking.

ringmybell commented 3 months ago

The error indicates a memory issue as far as I understand, I am getting std:bad_alloc error in Python shell. But nothing listed in dsmeg,. When it was actually throwing an out of memory issue before it was appearing in dsmeg, so I am thinking it is not a memory issue. Nothing in system logs (syslogs, messages)

I have increased the swap space from 100mb to 4096mb, but doesn't make any difference. I am watching memory usage in terminal through top and, while it is only updating once per second, I dont see memory drop to zero or swap memory increase from 0.

Any ideas on what the issue could be?

Here is the relative processing times I am getting when altering number of threads and images, I am trying to process 23 images into a stack. I also overclocked from 1.5 to 2Ghz and didn't make much difference.

Any ideas on how to speed the process up or how I could debug this?

image

PetteriAimonen commented 3 months ago

I would really like to see the --verbose log before making guesses at what it might be.

ringmybell commented 3 months ago

Which log, sorry I am not expert at this.

I have setup Python logging at DEBUG level and i doesn't show anything related to std:bad_alloc and Focus-Stack. Syslog and Daemon log same, doesn't appears anything related. I have tried running journalctl -f and nothing comes up.

ringmybell commented 3 months ago

Okay, I get it, add --verbonse to focus-stack command line. n00b.....

I have noticed it does always seem to fail on color reassignment map towards the end of the stacking process. I dont think the --verbose adds anything extra, but maybe I am missing something

focus-stack.txt

ringmybell commented 3 months ago

If it makes any difference. The images are already gray scale before entering focus stacking. Image is being captured by a Sony IMX477 camera module 12MP, image size resolution. 4056x3040.

PetteriAimonen commented 3 months ago

Hmm, for grayscale images the whole color reassignment map wouldn't really be needed at all. Might be worth it to add an option to skip that.