Skip to content

Commit

Permalink
[#2] add: 원본 이미지 블록 사이즈 확인 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryuchanghoon committed Feb 5, 2025
1 parent 7188e1a commit 6a68ae5
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions binari_adaptive_thresholding.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import cv2
import numpy as np
import matplotlib.pyplot as plt


image_path = "test.jpg"
image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)

height, width = image.shape
print(f'height: {height}, width: {width}') # 이미지 가로, 세로 크기

# 블록 크기에 따른 빨간 선
def draw_grid(image, block_size=51):
grid_img = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)
for x in range(0, width, block_size):
cv2.line(grid_img, (x, 0), (x, height), (0, 0, 255), 1)
for y in range(0, height, block_size):
cv2.line(grid_img, (0, y), (width, y), (0, 0, 255), 1)
return grid_img

block_check = draw_grid(image)

cv2.namedWindow('block check', cv2.WINDOW_NORMAL)
cv2.imshow('block check', block_check)


# ------ Mean Adaptive Thresholding -------

mean_bin = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 51, 10)
Expand Down

0 comments on commit 6a68ae5

Please sign in to comment.