image-js icon indicating copy to clipboard operation
image-js copied to clipboard

Implement function to align all images of a stack

Open opatiny opened this issue 2 years ago • 9 comments

  • we should probably implement the smartAlign algorithm that was developed in profid-padif-rework in image-js-ts
  • align all images
  • crop all images in order to have the same dimension of all the images once aligned

opatiny avatar Dec 15 '23 08:12 opatiny

This would be the equivalent of the matchAndCrop function currently in image-js.

opatiny avatar Dec 15 '23 10:12 opatiny

We have to add a new property to stacks called

private readonly translations: Point[];

We'll divide the alignment into two different methods

  1. align: modifies the translations property of the stack to have all the translations that have to be applied to the images to align them
  2. cropCommonArea: creates a new stack with the cropped images (all the same size). The translations of the new stack are all (0,0).

opatiny avatar Dec 15 '23 15:12 opatiny

  • Align of a stack will not be based on smartAlign!
  • The align method should work on images with different sizes.
  • The user should specify a maximal x and y displacement.
  • The pixels that don't overlap are ignored
  • For each translation, the similarity is computed and the position with the minimal similarity is written in the translations property.
  • All images are aligned on the first image of the stack? -> to be discussed

opatiny avatar Dec 22 '23 10:12 opatiny

Related: if we imagine the stack in 3D, is the first image (images[0]) at the bottom or at the top? In other words, if we look at the stack from above, which image do we see?

targos avatar Dec 22 '23 10:12 targos

Related: if we imagine the stack in 3D, is the first image (images[0]) at the bottom or at the top? In other words, if we look at the stack from above, which image do we see?

I feel like the order of the images should be the order in which you would show them if they were part of a movie. In other words, if you loop on the images, it should be the order in which they appear in the "animation".

opatiny avatar Dec 22 '23 12:12 opatiny

If the mental model of it is a movie, "Stack" seems like the wrong name 😕

targos avatar Dec 22 '23 12:12 targos

Indeed, that is how I considered them in my head, but maybe it's not the best. How would you imagine the stacks?

opatiny avatar Dec 22 '23 12:12 opatiny

I don't know, hence my question. In other image processing software, stacks do not represent videos. They are used to combine multiple images, for example to enhance quality and contrast in astrophotography.

targos avatar Dec 22 '23 12:12 targos

Wdyt @lpatiny ?

opatiny avatar Dec 22 '23 12:12 opatiny