MCPcopy
hub / github.com/sml2h3/ddddocr / numpy_to_image

Function numpy_to_image

ddddocr/utils/image_io.py:192–209  ·  view source on GitHub ↗

将numpy数组转换为PIL Image Args: array: numpy数组 mode: 图片模式,默认为'RGB' Returns: PIL Image对象 Raises: ImageProcessError: 当转换失败时

(array: np.ndarray, mode: str = 'RGB')

Source from the content-addressed store, hash-verified

190
191
192def numpy_to_image(array: np.ndarray, mode: str = 'RGB') -> Image.Image:
193 """
194 将numpy数组转换为PIL Image
195
196 Args:
197 array: numpy数组
198 mode: 图片模式,默认为'RGB'
199
200 Returns:
201 PIL Image对象
202
203 Raises:
204 ImageProcessError: 当转换失败时
205 """
206 try:
207 return Image.fromarray(array, mode=mode)
208 except Exception as e:
209 raise ImageProcessError(f"numpy数组转图片失败: {str(e)}") from e

Callers 3

filter_imageMethod · 0.85
remove_noiseMethod · 0.85
binarize_imageMethod · 0.85

Calls 1

ImageProcessErrorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…