내 이미지에 scikit 이미지의 적응 임계 값을 사용하려고합니다. 나는 HERE이미지에 Skimage 적응성 임계 값 사용 및 출력 얻기
import matplotlib.pyplot as plt
from skimage import data
from skimage.filters import threshold_otsu, threshold_adaptive
image = data.page()
global_thresh = threshold_otsu(image)
binary_global = image > global_thresh
block_size = 35
binary_adaptive = threshold_adaptive(image, block_size, offset=10)
fig, axes = plt.subplots(nrows=3, figsize=(7, 8))
ax0, ax1, ax2 = axes
plt.gray()
ax0.imshow(image)
ax0.set_title('Image')
ax1.imshow(binary_global)
ax1.set_title('Global thresholding')
ax2.imshow(binary_adaptive)
ax2.set_title('Adaptive thresholding')
for ax in axes:
ax.axis('off')
plt.show()
코드는, 샘플 이미지에서 소요를 임계 값과 PLT를 사용하여 보여줍니다에서 자신의 샘플 코드를 테스트했다. 그러나, 나는 thresholded 이미지의 numpy 배열을 검색하려고합니다. 변수 binary_global
에 cv2.imwrite
을 사용하려고 시도했지만 작동하지 않습니다. binary_global
을 인쇄 할 때 실제로는 숫자가 아닌 거짓과 참 값으로 구성된 배열입니다. plt가 어떻게 그것을 사용하고 이미지를 만들 수 있는지 잘 모르겠습니다. 그럼에도 불구하고 어떻게 이미지를 임계 값으로 설정하고 RGB 값으로 새 임계 값 이미지의 배열을 검색 할 수 있습니까?
을 작성하기위한
img
를 사용할 수있는 변경 사항 - 참조 다음 추가 # working-with-opencv –이것은 완벽하게 작동했습니다. – Jess