forked from gzr2017/ImageProcessing100Wen
-
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.
- Loading branch information
Showing
80 changed files
with
4,513 additions
and
4,492 deletions.
There are no files selected for viewing
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.
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.
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.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import cv2 | ||
|
||
# function: BGR -> RGB | ||
|
||
|
||
def BGR2RGB(img): | ||
b = img[:, :, 0].copy() | ||
g = img[:, :, 1].copy() | ||
r = img[:, :, 2].copy() | ||
|
||
# RGB > BGR | ||
img[:, :, 0] = r | ||
img[:, :, 1] = g | ||
img[:, :, 2] = b | ||
|
||
return img | ||
|
||
|
||
# Read image | ||
img = cv2.imread("../imori.jpg") | ||
|
||
# BGR -> RGB | ||
img = BGR2RGB(img) | ||
|
||
# Save result | ||
cv2.imwrite("out.jpg", img) | ||
cv2.imshow("result", img) | ||
cv2.waitKey(0) | ||
cv2.destroyAllWindows() | ||
import cv2 | ||
|
||
# function: BGR -> RGB | ||
|
||
|
||
def BGR2RGB(img): | ||
b = img[:, :, 0].copy() | ||
g = img[:, :, 1].copy() | ||
r = img[:, :, 2].copy() | ||
|
||
# RGB > BGR | ||
img[:, :, 0] = r | ||
img[:, :, 1] = g | ||
img[:, :, 2] = b | ||
|
||
return img | ||
|
||
|
||
# Read image | ||
img = cv2.imread("../imori.jpg") | ||
|
||
# BGR -> RGB | ||
img = BGR2RGB(img) | ||
|
||
# Save result | ||
cv2.imwrite("out.jpg", img) | ||
cv2.imshow("result", img) | ||
cv2.waitKey(0) | ||
cv2.destroyAllWindows() |
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 |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import cv2 | ||
import numpy as np | ||
|
||
# Gray scale | ||
|
||
|
||
def BGR2GRAY(img): | ||
b = img[:, :, 0].copy() | ||
g = img[:, :, 1].copy() | ||
r = img[:, :, 2].copy() | ||
|
||
# Gray scale | ||
out = 0.2126 * r + 0.7152 * g + 0.0722 * b | ||
out = out.astype(np.uint8) | ||
|
||
return out | ||
|
||
# binalization | ||
|
||
|
||
def binarization(img, th=128): | ||
img[img < th] = 0 | ||
img[img >= th] = 255 | ||
return img | ||
|
||
|
||
# Read image | ||
img = cv2.imread("../imori.jpg").astype(np.float32) | ||
|
||
# Grayscale | ||
out = BGR2GRAY(img) | ||
|
||
# Binarization | ||
out = binarization(out) | ||
|
||
# Save result | ||
cv2.imwrite("out.jpg", out) | ||
cv2.imshow("result", out) | ||
cv2.waitKey(0) | ||
cv2.destroyAllWindows() | ||
import cv2 | ||
import numpy as np | ||
|
||
# Gray scale | ||
|
||
|
||
def BGR2GRAY(img): | ||
b = img[:, :, 0].copy() | ||
g = img[:, :, 1].copy() | ||
r = img[:, :, 2].copy() | ||
|
||
# Gray scale | ||
out = 0.2126 * r + 0.7152 * g + 0.0722 * b | ||
out = out.astype(np.uint8) | ||
|
||
return out | ||
|
||
# binalization | ||
|
||
|
||
def binarization(img, th=128): | ||
img[img < th] = 0 | ||
img[img >= th] = 255 | ||
return img | ||
|
||
|
||
# Read image | ||
img = cv2.imread("../imori.jpg").astype(np.float32) | ||
|
||
# Grayscale | ||
out = BGR2GRAY(img) | ||
|
||
# Binarization | ||
out = binarization(out) | ||
|
||
# Save result | ||
cv2.imwrite("out.jpg", out) | ||
cv2.imshow("result", out) | ||
cv2.waitKey(0) | ||
cv2.destroyAllWindows() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.