PetteriAimonen / focus-stack

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

Request: Different fill method / ignore unavailable areas #22

Open LGimmick opened 2 years ago

LGimmick commented 2 years ago

Hi again,

I know that this is maybe a bit much to ask, as it may collide with some general concepts of your stacking method, but anyway:

I usually add some informations like a description, scale, ... to the image using some simple layers as overlay for this task. But the elements in the layer have absolute coordinates - if the image is smaller than expected they are positioned outside of the image.

That would not be a problem, since the rectangle is available, but the mirroring creates artifacts, that are not actually part of the original images. Therefore it would be genius, if the filling for reconstruction could be changed, or areas outside the layers valid-boxes could be ignored.

I think using/ignoring transparency would be more complicated, but would have the benefit that it would maybe be a first step towards manual "masking" (just delete parts from an image) like in enfuse.

PetteriAimonen commented 2 years ago

Different fill method would be great, but currently I don't know of one that would be easy to implement and would avoid discontinuities near the edges. Probably some kind of blurring would work, but it has to be fast.

Adding text to image before stacking is likely to be problematic, I would suggest adding it to the final image.

LGimmick commented 2 years ago

That's a small case of lost-in-translation: I add the text to the final image, as an overlay. But the size of the final image depends on the offsets. But I think I can split the overlay into parts depending on the "anchor side" and align them in relative position to the borders or place the result image centered on a white/transparent background.

C++ is realy by far not somethingI know anything about - the idea was something like: If I understand it correctly in task_merge.cc at line 49 you loop through the values of all wavelet results, looking for the max value. Wouldn't it be possible to value any wavelet value outside of the valid-box with "-1" or ignore it and therefore - if the reference image has no offset - in the worst case the highest value is always the first image? Or am I talking rubbish and this would create artifacts at the border? :D

PetteriAimonen commented 2 years ago

The wavelets extend beyond the image borders, that is the reason it has to be padded to a multiple of 2^n before processing. E.g. at wavelet level 6, each wavelet corresponds to a 448 pixel wide area. Example image here: https://github.com/PetteriAimonen/focus-stack/blob/master/docs/Algorithms.md#complex-wavelet-transform

The lower downsampling wavelet levels have correspondingly smaller support areas in the original image. It's possible to do all kinds of fun modifications (I'm trying to implement #8 currently), but it is easy to end up with ripple artifacts that look like what would result from jpeg compression.

(The wavelets are still a bit of magic for me also, they just seem to work well for image stacking.)

LGimmick commented 2 years ago

Hmm, ok, so the wavelets do not realy contain an image like an edge-detection-image, but they are more like a pyramid with different frequencies? And therefore directly editing values of the wavelets in dependency of the x,y coordinates of the image is not possible?

I thought it's maybe possible to add min-values in your get_sg_absval - method, so the iteration does not run from 0->maxrow/column, but only from valid-rect-left to valid-rect-right... and so on or set absval.at(y, x) for x,y outside the rect to 0 - or some thing like that :D