-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed 21c91ec with MkDocs version: 1.6.1
- Loading branch information
0 parents
commit 93adfe1
Showing
74 changed files
with
23,324 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import cv2 | ||
from PIL import Image | ||
import numpy as np | ||
|
||
# 读取图像 | ||
image = cv2.imread('zhao.png') | ||
|
||
# 将图像从BGR转换到灰度 | ||
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | ||
|
||
# 应用阈值操作, | ||
# 将灰度图像转换为二值图像 | ||
_, thresh_image = cv2.threshold(gray_image, 70, 255, cv2.THRESH_BINARY) | ||
|
||
# 创建alpha通道,黑色部分为0(透明),白色部分为255(不透明) | ||
alpha_channel = 255 - thresh_image | ||
|
||
# 创建全白色的图像、 | ||
# 用于合并到alpha通道中 | ||
white_image = 255 * np.ones_like(gray_image) | ||
|
||
# 将BGR图像和alpha通道合并成BGRA格式 | ||
bgra_image = cv2.merge((white_image, alpha_channel)) | ||
|
||
# 使用Pillow库保存图像,因为OpenCV不支持保存PNG透明图像 | ||
pil_image = Image.fromarray(bgra_image) | ||
pil_image = pil_image.convert("RGBA") # 确保图像是RGBA格式 | ||
pil_image.save('zhao.png', 'PNG') | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.