imgly / background-removal-js

Remove backgrounds from images directly in the browser environment with ease and no additional costs or privacy concerns. Explore an interactive demo.
https://img.ly/showcases/cesdk/web/background-removal/web
GNU Affero General Public License v3.0
5.49k stars 339 forks source link

no way to generate proper mask #101

Closed mtrabelsi closed 4 months ago

mtrabelsi commented 5 months ago

The docs looks incorrect about TS types, in the nodejs example you are getting mask from:

const mask= await segmentForeground(imagePath, config);

in other examples or in the docs, you are hinting that you can set it in the config:

      output: {
        quality: 1,
        format: 'image/webp', //image/jpeg, image/webp
        type: 'mask'//  'foreground' | 'background' | 'mask'
      }

which is incorrect and does not work, I checked the code you are not reading from type config to get the mask.

now if I use segmentForeground() - which seems the only way that "works" in your examples, I get this which is not a typical mask, why its blueish-purple color?

image
DanielHauschildt commented 4 months ago

Thanks for pointing this out.

The mask is currently a rgba image with each channel habe the same mask data. You can just use any channel and use is as alphamask for another image.

How would you like the mask to be provided?