edcamcam_testfile_imgproc9.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码
def SpaceFunc(matr):
    matr_shape = matr.shape
    spa_X_array = np.array([])
    spa_Y_array = np.array([])
    val_X_matrix = np.zeros((matr_shape[0], matr_shape[1]), dtype=np.ndarray)
    val_Y_matrix = np.zeros((matr_shape[0], matr_shape[1]), dtype=np.ndarray)
    val_X_matrix_counter = np.zeros((matr_shape[0], matr_shape[1]), dtype=np.ndarray)
    val_Y_matrix_counter=np.zeros((matr_shape[0], matr_shape[1]), dtype=np.ndarray)


    counter_g1 = 0
    while counter_g1 < matr_shape[1]:
        counter_g2 = 0
        while counter_g2 < matr_shape[0]:
            matr_value = matr[counter_g2, counter_g1]
            matr_value=np.asarray(matr_value)

            if matr_value.size==3:
                val_X_matrix[counter_g2, counter_g1] = matr_value[0]
                val_Y_matrix[counter_g2, counter_g1] = matr_value[1]
                val_X_matrix_counter[counter_g2, counter_g1] = 1
                val_Y_matrix_counter[counter_g2, counter_g1] = 1
            elif matr_value.size == 0:
                val_X_matrix[counter_g2, counter_g1] = 0
                val_Y_matrix[counter_g2, counter_g1] = 0
                val_X_matrix_counter[counter_g2, counter_g1] = 0
                val_Y_matrix_counter[counter_g2, counter_g1] = 0
            counter_g2 = counter_g2 + 1
        counter_g1 = counter_g1 + 1

    val_X_array_counter = val_X_matrix_counter.sum(axis=0)
    val_Y_array_counter = val_Y_matrix_counter.sum(axis=1)
    val_X_array_acc = val_X_matrix.sum(axis=0)
    val_Y_array_acc=val_Y_matrix.sum(axis=1)
    val_X_array = val_X_array_acc/val_X_array_counter
    val_Y_array = val_Y_array_acc / val_Y_array_counter

    spa_X_array=np.ediff1d(val_X_array)
    spa_Y_array=np.ediff1d(val_Y_array)

#Creating function to convert matrix to binary (those with value to 1, those with 0 to 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号