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

Erosion and dilatation are inverted #378

Closed Xstoudi closed 1 year ago

Xstoudi commented 1 year ago

Consider the following image. image

Run this script in the same folder:

const { readSync, writeSync } = require('image-js')

const image = readSync('image.png').grey().threshold({algorithm: 'otsu'})
writeSync('image-threshold.png', image)
writeSync('image-eroded.png', image.erode())
writeSync('image-dilated.png', image.dilate())

Outputed image are the following.

image.erode(): image-eroded

image.dilate(): image-dilated

Xstoudi commented 1 year ago

My bad I obviously inverted white and black meaning myself. Nothing problematic here.