Esempio n. 1
0
    def f2():
        img = cv2.imread(get_filename('0d648f99c.jpg', 'Train'),
                         cv2.IMREAD_GRAYSCALE)
        img = gaussian(img, 0.5)
        # img = cv2.resize(img, dsize=tile_size)

        em_object = EM(img)
        em_object.run_it()
Esempio n. 2
0
def process_image(image_id, thread_number, locale):
    try:
        print("%d start" % thread_number)
        img = cv2.imread(get_filename(image_id, "final"), cv2.IMREAD_GRAYSCALE)
        img = gaussian(img, 0.5)  # TODO maybe change to 1

        final_img = img.copy()
        img = cv2.resize(img, dsize=tile_size)

        print("%d go EM" % thread_number)
        em = EM(img, thread_number)
        em.run_it()

        print("%d done EM" % thread_number)

        st = timer()
        prediction_matrix = create_prediction_image(final_img, em.miu,
                                                    em.sigma, em.pgk,
                                                    em.clusters)
        fs = timer()

        print('Prediciton matrix %d' % (fs - st))

        out_file = open("../EM_Result/%s" % image_id.split(".")[0], "w")

        for line in prediction_matrix:
            for el in line:
                out_file.write("%d " % el)
            out_file.write("\n")
        out_file.close()

        thread_file = open("../EM_Result/_Thread_%d" % thread_number, "a")
        thread_file.write(image_id)
        thread_file.write("\n")
        thread_file.close()
    except Exception as e:
        print(e)
        th_err = open("../EM_Result/_Thread_Error_%d" % thread_number, "a")
        th_err.write(image_id)
        th_err.write("\n")
        th_err.close()