imbinarize
imbinarize(img: np.ndarray, threth: int = cv2.THRESH_BINARY, color_base: str = "BGR") -> np.ndarray
-
Description: Performs binarization on the input image.
-
Parameters
- img (
np.ndarray): The input image to binarize. If it has 3 channels, it is converted to grayscale viaimcvtcolor(..., f\"{color_base}2GRAY\")first. - threth (
int): The threshold type. There are two threshold types:cv2.THRESH_BINARY:cv2.THRESH_OTSU + cv2.THRESH_BINARYcv2.THRESH_BINARY_INV:cv2.THRESH_OTSU + cv2.THRESH_BINARY_INV
- color_base (
str): The color space of the input image. Default is'BGR'.
- img (
-
Returns
- np.ndarray: The binarized image.
-
Example
import capybara as cb
img = cb.imread('lena.png')
bin_img = cb.imbinarize(img)