Skip to content

Commit

Permalink
Merge pull request gzr2017#15 from kokosabu/q16_fix
Browse files Browse the repository at this point in the history
Q.16の修正
  • Loading branch information
yoyoyo-yo authored Feb 26, 2019
2 parents 1fc676b + f13149e commit dee6d36
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Question_11_20/answer_16.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
tmp = out.copy()

## Sobel vertical
#K = [[1., 0., -1.],[1., 0., -1.],[1., 0., -1.]]
#K = [[-1., 0., 1.],[-1., 0., 1.],[-1., 0., 1.]]
## Sobel horizontal
K = [[-1., -1., -1.],[0., 0., 0.], [1., 1., 1.]]

for y in range(H):
for x in range(W):
out[pad+y, pad+x] = np.mean(K * (tmp[y:y+K_size, x:x+K_size]))
out[pad+y, pad+x] = np.sum(K * (tmp[y:y+K_size, x:x+K_size]))

out = out[pad:pad+H, pad:pad+W].astype(np.uint8)

out[out < 0] = 0
out[out > 255] = 255

# Save result
cv2.imwrite("out.jpg", out)
cv2.imshow("result", out)
Expand Down
Binary file modified Question_11_20/answer_16_h.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Question_11_20/answer_16_v.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dee6d36

Please sign in to comment.