|
| 1 | +## Sharpen |
| 2 | + |
| 3 | +Sharpens an image through the unsharp masking method. Applies a gaussian blur which is subtracted from an exaggerated version of the starting image. |
| 4 | + |
| 5 | +**plantcv.sharpen**(*img, ksize, amount=1, threshold=0, sigma_x=0, sigma_y=None, roi=None*) |
| 6 | + |
| 7 | +**returns** sharpened image |
| 8 | + |
| 9 | +- **Parameters:** |
| 10 | + - img - RGB or grayscale image data |
| 11 | + - ksize - Tuple of kernel dimensions, e.g. (5, 5). Must be odd integers. |
| 12 | + - amount - Integer describing amount of sharpening, higher numbers will sharpen more. |
| 13 | + - threshold - Integer cutoff on low contrast, contrasts lower than this will be removed. |
| 14 | + - sigma_x - standard deviation in X direction; if 0 (default), calculated from kernel size |
| 15 | + - sigma_y - standard deviation in Y direction; if sigma_Y is None (default), sigma_Y is taken to equal sigma_X |
| 16 | + - roi - Optional rectangular ROI as returned by [`pcv.roi.rectangle`](roi_rectangle.md) within which to apply this function. (default = None, which uses the entire image) |
| 17 | +- **Context:** |
| 18 | + - Used to reduce blur in an image |
| 19 | + |
| 20 | +**Original image** |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +**Sharpening Image** |
| 25 | + |
| 26 | +```python |
| 27 | + |
| 28 | +# Apply sharpening within an ROI to show differences |
| 29 | +roi = pcv.roi.rectangle(img, 200, 0, 335, 200) |
| 30 | +sharp1 = pcv.sharpen(img, (5, 5), amount=1, roi=roi) |
| 31 | + |
| 32 | +# Higher amount of sharpening will look more dramatic |
| 33 | +sharp5 = pcv.sharpen(img, (5, 5), amount = 5, roi=roi) |
| 34 | +``` |
| 35 | + |
| 36 | +**Sharpen (ksize = (5,5), amount=1, roi=roi)** |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +**Sharpen (ksize = (5,5), amount=5, roi=roi)** |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +**Source Code:** [Here](https://github.com/danforthcenter/plantcv/blob/main/plantcv/plantcv/sharpen.py) |
0 commit comments