image-js / image-js-typescript

Temporary repository to work on the migration of image-js to TypeScript
https://image-js.github.io/image-js-typescript/
MIT License
5 stars 5 forks source link

feat: add background correction #449

Closed EscapedGibbon closed 3 months ago

EscapedGibbon commented 4 months ago

https://github.com/image-js/image-js-typescript/issues/275

EscapedGibbon commented 4 months ago

Why the corrected image is inverted in the snapshot ?

image

This is the image subtractBackground returns. Should I add an inversion to the function so that it gives an inverted result?

lpatiny commented 4 months ago

This is the image subtractBackground returns. Should I add an inversion to the function so that it gives an inverted result?

This image is expected to return the corrected image or the background ? Based on the name a would expect the corrected image so it should be pretty close to the original image.

EscapedGibbon commented 4 months ago

This is the image subtractBackground returns. Should I add an inversion to the function so that it gives an inverted result?

This image is expected to return the corrected image or the background ? Based on the name a would expect the corrected image so it should be pretty close to the original image.

Something like this? cannyEdgeOutBack

lpatiny commented 4 months ago

Indeed this looks more like what I expect.

lpatiny commented 3 months ago

@EscapedGibbon Please could you rename everything to 'correctBackground' because subtract is confusing. In the example you actually add it.

lpatiny commented 3 months ago

@EscapedGibbon Seems this function is not exposed. Pleaxe expose it as static !

targos commented 3 months ago

@lpatiny I don't like the use of a fixed value for the default grid size:

lpatiny commented 3 months ago

@lpatiny I don't like the use of a fixed value for the default grid size:

  • It doesn't scale with the image's size
  • It makes the method throw by default when the image is small enough

I was thinking that this was a good compromise because we fit by a polynomial of degree 2 (aX^2 + bX + cY^2 + dY + eXY + f) so 6 parameters. It does not make sense to have much more points and it does not make sense I think to try to remove a background of an image that is less that 10x10.

But if you have other idea you may ask Maxim to change it.