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

Implement `hitMiss()` #42

Open opatiny opened 2 years ago

opatiny commented 2 years ago

This function applies a kernel to an image. The kernel should contain three possible values: 0, 1 and NaN. The pixels in the result are set to 1 iif the pixels surrounding it in the original match the pattern of 0 and 1 defined by the kernel.

https://homepages.inf.ed.ac.uk/rbf/HIPR2/hitmiss.htm

The following lines could be copied / adapted. The computeConvolutionPixel() function should ignore kernel values set to NaN. Don't forget to use isNan().

https://github.com/image-js/image-js-typescript/blob/be36409d09cc18d8d733ed357ef8f00144022335/src/filters/convolution.ts#L146-L176

lpatiny commented 2 years ago

Currently we don't see any application for this so it is not on the priority list.