Sharp: Enhancing clarity of an image

Created on 13 Dec 2017  路  1Comment  路  Source: lovell/sharp

Hey I have an image that I will be passing into tesseract, but before passing it in I need to enhance the "clarity" of the image for ocr. I can do this through windows photos "Edit=>Clarity" but want to know how I can get the same effect using sharp

Thanks

enhancement

Most helpful comment

Hello, I may be wrong but I think this feature involves a technique called Contrast Limited Adaptive Histogram Equalization.

If so, libvips provides this via hist_local but this is not yet exposed in sharp.

The API could possibly look like something like the following:

.clarity({ width: 5, height: 5, slope: 3.0 })

...where width and height must be odd integers (default requires experimentation, perhaps 5 or 7) and slope will typically be a float between 2.0 and 4.0 (default to 3.0).

>All comments

Hello, I may be wrong but I think this feature involves a technique called Contrast Limited Adaptive Histogram Equalization.

If so, libvips provides this via hist_local but this is not yet exposed in sharp.

The API could possibly look like something like the following:

.clarity({ width: 5, height: 5, slope: 3.0 })

...where width and height must be odd integers (default requires experimentation, perhaps 5 or 7) and slope will typically be a float between 2.0 and 4.0 (default to 3.0).

Was this page helpful?
0 / 5 - 0 ratings