Esempio n. 1
0
def temp_filter_method_adaptive_thresholding(imageFile):
    img = data.imread(imageFile, as_grey=True)

    global_thresh = threshold_yen(img)
    # True False binary matrix represent color value of the img using global thresholding
    binary_global = img > global_thresh

    block_size = 40

    # True False binary matrix represent color value of the img using adaptive thresholding
    binary_adaptive = threshold_adaptive(img, block_size, offset=0)

    # 0 1 binary matrix
    img_bin_global = clear_border(img_as_uint(binary_global))

    # 0 1 binary matrix 
    img_bin_adaptive = clear_border(img_as_uint(binary_adaptive))


    bin_pos_mat = ocr.binary_matrix_to_position(binary_adaptive)

    np.savetxt("test.txt",bin_pos_mat) # %.5f specifies 5 decimal round
Esempio n. 2
0
File: filter.py Progetto: dyther/OCR
global_thresh = threshold_yen(img)
# True False binary matrix represent color value of the img using global thresholding
binary_global = img > global_thresh

block_size = 40

# True False binary matrix represent color value of the img using adaptive thresholding
binary_adaptive = threshold_adaptive(img, block_size, offset=10)

# 0 1 binary matrix
img_bin_global = clear_border(img_as_uint(binary_global))

# 0 1 binary matrix
img_bin_adaptive = clear_border(img_as_uint(binary_adaptive))

bin_pos_mat = ocr.binary_matrix_to_position(binary_adaptive)

np.savetxt("test.txt", bin_pos_mat)  # %.5f specifies 5 decimal round

fig, axes = plt.subplots(nrows=3, figsize=(7, 8))
ax0, ax1, ax2 = axes
figure(1)
subplot(311)
imshow(image)
subplot(312)
scatter(bin_pos_mat[:, 1], bin_pos_mat[:, 0])
# imshow(np.flipud(clustered))
subplot(313)
imshow(binary_adaptive)

show()
Esempio n. 3
0
# True False binary matrix represent color value of the img using global thresholding
binary_global = img > global_thresh

block_size = 40

# True False binary matrix represent color value of the img using adaptive thresholding
binary_adaptive = threshold_adaptive(img, block_size, offset=10)

# 0 1 binary matrix
img_bin_global = clear_border(img_as_uint(binary_global))

# 0 1 binary matrix 
img_bin_adaptive = clear_border(img_as_uint(binary_adaptive))


bin_pos_mat = ocr.binary_matrix_to_position(binary_adaptive)

np.savetxt("test.txt",bin_pos_mat) # %.5f specifies 5 decimal round

fig, axes = plt.subplots(nrows=3, figsize=(7, 8))
ax0, ax1, ax2 = axes
figure(1)
subplot(311)
imshow(image)
subplot(312)
scatter(bin_pos_mat[:,1], bin_pos_mat[:,0])
# imshow(np.flipud(clustered))
subplot(313)
imshow(binary_adaptive)

show()
Esempio n. 4
0
    print bin_pos_mat
    # np.savetxt("test.txt",bin_pos_mat)
=======
	from skimage.data import camera
	from skimage import data, img_as_uint, img_as_float
	from skimage.filters import roberts, sobel, scharr, prewitt

	imageFile = '../pics/beach2.png'
	
	image = data.imread(imageFile, as_grey=True)
	
	edge_roberts = roberts(image)
	
	edge_sobel = sobel(image)
	
	bin_pos_mat = ocr.binary_matrix_to_position(edge_sobel)
	np.savetxt("test.txt",bin_pos_mat)
>>>>>>> 57878957f56a122b604e36c48abb4757808fca1d
	



#============================================================

#============================================================
# comment out either temp_filter_method_adaptive_thresholding() 
# or temp_filter_method_kmeans_color() to try out
# the two different filtering methods
#============================================================
#============================================================