def minutiae_whole_image(model_path,
                         sample_path,
                         imgs,
                         output_name='reconstruction/gen:0'):
    imgs = glob.glob('/Data/Rolled/NISTSD14/Image2/*.bmp')
    imgs.sort()

    with tf.Graph().as_default():
        with TowerContext('', is_training=False):
            with tf.Session() as sess:
                is_training = get_current_tower_context().is_training
                load_model(model_path)
                images_placeholder = tf.get_default_graph().get_tensor_by_name(
                    'QueueInput/input_deque:0')
                # is_training
                minutiae_cylinder_placeholder = tf.get_default_graph(
                ).get_tensor_by_name(output_name)
                for n, file in enumerate(imgs):
                    img0 = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
                    img = img0 / 128.0 - 1
                    img = np.expand_dims(img, axis=2)
                    img = np.expand_dims(img, axis=0)
                    feed_dict = {images_placeholder: img}
                    minutiae_cylinder = sess.run(minutiae_cylinder_placeholder,
                                                 feed_dict=feed_dict)

                    minutiae_cylinder = np.squeeze(minutiae_cylinder, axis=0)
                    minutiae = prepare_data.get_minutiae_from_cylinder(
                        minutiae_cylinder, thr=0.25)
                    minutiae = prepare_data.refine_minutiae(minutiae,
                                                            dist_thr=10,
                                                            ori_dist=np.pi / 4)
                    prepare_data.show_minutiae(img0, minutiae)
                    print n
Esempio n. 2
0
    def run(self, img, minu_thr=0.2):
        h, w = img.shape
        weight = get_weights(128, 128, 12)
        nrof_samples = len(range(0, h, opt.SHAPE // 2)) * len(range(0, w, opt.SHAPE // 2))
        patches = np.zeros((nrof_samples, opt.SHAPE, opt.SHAPE, 1))
        n = 0
        x = []
        y = []
        for i in range(0, h - opt.SHAPE + 1, opt.SHAPE // 2):
            for j in range(0, w - opt.SHAPE + 1, opt.SHAPE // 2):
                patch = img[i:i + opt.SHAPE, j:j + opt.SHAPE, np.newaxis]
                x.append(j)
                y.append(i)
                patches[n, :, :, :] = patch
                n = n + 1
        feed_dict = {self.images_placeholder: patches}
        minutiae_cylinder_array = self.sess.run(self.minutiae_cylinder_placeholder, feed_dict=feed_dict)
        minutiae_cylinder = np.zeros((h, w, 12))
        minutiae_cylinder_array[:, -10:, :, :] = 0
        minutiae_cylinder_array[:, :10, :, :] = 0
        minutiae_cylinder_array[:, :, -10:, :] = 0
        minutiae_cylinder_array[:, :, 10, :] = 0

        for i in range(n):
            minutiae_cylinder[y[i]:y[i] + opt.SHAPE, x[i]:x[i] + opt.SHAPE, :] = minutiae_cylinder[
                y[i]:y[i] + opt.SHAPE,
                x[i]:x[i] + opt.SHAPE, :] + \
                minutiae_cylinder_array[i] * weight
        minutiae = prepare_data.get_minutiae_from_cylinder(minutiae_cylinder, thr=minu_thr)
        minutiae = prepare_data.refine_minutiae(minutiae, dist_thr=10, ori_dist=np.pi / 4)
        minutiae = self.remove_crowded_minutiae(minutiae)
        minutiae = np.asarray(minutiae)
        return minutiae
Esempio n. 3
0
def minutiae_extraction3(model_path, sample_path, imgs, output_name='reconstruction/gen:0', block=True):
    imgs = glob.glob('/research/prip-kaicao/Data/Rolled/NIST4/Image/' + '*.bmp')

    imgs.sort()

    import os
    if not os.path.isdir(sample_path):
        os.makedirs(sample_path)

    weight = get_weights(opt.SHAPE, opt.SHAPE, 12)
    with tf.Graph().as_default():

        with TowerContext('', is_training=False):
            with tf.Session() as sess:
                is_training = get_current_tower_context().is_training
                load_model(model_path)
                images_placeholder = tf.get_default_graph().get_tensor_by_name('sub:0')
                minutiae_cylinder_placeholder = tf.get_default_graph().get_tensor_by_name(output_name)
                for k, file in enumerate(imgs):
                    img = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
                    h, w = img.shape
                    x = []
                    y = []
                    nrof_samples = len(range(0, h, opt.SHAPE // 2)) * len(range(0, w, opt.SHAPE // 2))
                    patches = np.zeros((nrof_samples, opt.SHAPE, opt.SHAPE, 1))
                    n = 0
                    for i in range(0, h - opt.SHAPE + 1, opt.SHAPE // 2):

                        for j in range(0, w - opt.SHAPE + 1, opt.SHAPE // 2):
                            print j
                            patch = img[i:i + opt.SHAPE, j:j + opt.SHAPE, np.newaxis]
                            x.append(j)
                            y.append(i)
                            patches[n, :, :, :] = patch
                            n = n + 1
                        # print x[-1]
                    feed_dict = {images_placeholder: patches}
                    minutiae_cylinder_array = sess.run(minutiae_cylinder_placeholder, feed_dict=feed_dict)

                    minutiae_cylinder = np.zeros((h, w, 12))
                    minutiae_cylinder_array[:, -10:, :, :] = 0
                    minutiae_cylinder_array[:, :10, :, :] = 0
                    minutiae_cylinder_array[:, :, -10:, :] = 0
                    minutiae_cylinder_array[:, :, 10, :] = 0
                    for i in range(n):
                        minutiae_cylinder[y[i]:y[i] + opt.SHAPE, x[i]:x[i] + opt.SHAPE, :] = minutiae_cylinder[y[i]:y[i] +
                            opt.SHAPE, x[i]:x[i] + opt.SHAPE, :] + minutiae_cylinder_array[i] * weight

                    minutiae = prepare_data.get_minutiae_from_cylinder(minutiae_cylinder, thr=0.1)
                    minutiae = prepare_data.refine_minutiae(minutiae, dist_thr=10, ori_dist=np.pi / 4)
                    minutiae_sets = []
                    minutiae_sets.append(minutiae)

                    fname = sample_path + os.path.basename(file)[:-4] + 'nms' + '.jpeg'
                    prepare_data.show_minutiae_sets(img, minutiae_sets, ROI=None, fname=fname, block=block)

                    print(n)
Esempio n. 4
0
    def run(self, img,minu_thr=0.2):
        #feed_dict = {self.images_placeholder: img}
        #minutiae_cylinder = self.sess.run(self.minutiae_cylinder_placeholder, feed_dict=feed_dict)

        h,w = img.shape
        weight = get_weights(128, 128, 12)
        nrof_samples = len(range(0, h, opt.SHAPE // 2)) * len(range(0, w, opt.SHAPE // 2))
        patches = np.zeros((nrof_samples, opt.SHAPE, opt.SHAPE, 1))
        n = 0
        x = []
        y = []
        for i in range(0, h - opt.SHAPE + 1, opt.SHAPE // 2):

            for j in range(0, w - opt.SHAPE + 1, opt.SHAPE // 2):
                #print j
                patch = img[i:i + opt.SHAPE, j:j + opt.SHAPE, np.newaxis]
                x.append(j)
                y.append(i)
                patches[n, :, :, :] = patch
                n = n + 1
                # print x[-1]
        feed_dict = {self.images_placeholder: patches}
        minutiae_cylinder_array = self.sess.run(self.minutiae_cylinder_placeholder, feed_dict=feed_dict)
        minutiae_cylinder = np.zeros((h, w, 12))
        minutiae_cylinder_array[:, -10:, :, :] = 0
        minutiae_cylinder_array[:, :10, :, :] = 0
        minutiae_cylinder_array[:, :, -10:, :] = 0
        minutiae_cylinder_array[:, :, 10, :] = 0

        for i in range(n):
            minutiae_cylinder[y[i]:y[i] + opt.SHAPE, x[i]:x[i] + opt.SHAPE, :] = minutiae_cylinder[
                                                                                 y[i]:y[i] + opt.SHAPE,
                                                                                 x[i]:x[i] + opt.SHAPE, :] + \
                                                                                 minutiae_cylinder_array[i] * weight
        # print minutiae_cylinder
        minutiae = prepare_data.get_minutiae_from_cylinder(minutiae_cylinder, thr=minu_thr)

        # cv2.imwrite('test_0.jpeg', (minutiae_cylinder[:, :, 0:3]) * 255)
        # cv2.imwrite('test_1.jpeg', (minutiae_cylinder[:, :, 3:6]) * 255)
        # cv2.imwrite('test_2.jpeg', (minutiae_cylinder[:, :, 6:9]) * 255)
        # cv2.imwrite('test_3.jpeg', (minutiae_cylinder[:, :, 9:12]) * 255)
        # prepare_data.show_features(img, minutiae, fname=os.path.basename(file)[:-4] +'.jpeg')

        minutiae = prepare_data.refine_minutiae(minutiae, dist_thr=10, ori_dist=np.pi / 4)

        minutiae = self.remove_crowded_minutiae(minutiae)
        return minutiae
Esempio n. 5
0
def minutiae_whole_image(model_path,sample_path, imgs, output_name='reconstruction/gen:0'):
    #imgs = glob.glob('/media/kaicao/Data/Data/Rolled/NISTSD4/Image_Aligned'+'/*.jpeg')
    #imgs = glob.glob('/home/kaicao/Dropbox/Research/Data/Latent/NISTSD27/image/'+'*.bmp')
    imgs = glob.glob('/future/Data/Rolled/NISTSD14/Image2/*.bmp')
    #imgs = glob.glob('/research/prip-kaicao/Data/Latent/DB/NIST27/image/' + '*.bmp')
    #imgs = glob.glob('/research/prip-kaicao/Data/Rolled/NIST4/Image/'+'*.bmp')
    imgs.sort()
    weight = get_weights(opt.SHAPE, opt.SHAPE, 12)
    import os
    #if not os.path.isdir(sample_path):
    #    os.makedirs(sample_path)
    with tf.Graph().as_default():

        with TowerContext('', is_training=False):
            with tf.Session() as sess:
                is_training= get_current_tower_context().is_training
                load_model(model_path)
                images_placeholder = tf.get_default_graph().get_tensor_by_name('QueueInput/input_deque:0')
                #is_training
                minutiae_cylinder_placeholder = tf.get_default_graph().get_tensor_by_name(output_name)
                for n, file in enumerate(imgs):
                    img0 = cv2.imread(file,cv2.IMREAD_GRAYSCALE)
                    img = img0/128.0-1
                    img = np.expand_dims(img,axis=2)
                    img = np.expand_dims(img,axis=0)
                    feed_dict = {images_placeholder: img}
                    minutiae_cylinder= sess.run(minutiae_cylinder_placeholder, feed_dict=feed_dict)

                    minutiae_cylinder = np.squeeze(minutiae_cylinder,axis=0)
                    minutiae = prepare_data.get_minutiae_from_cylinder(minutiae_cylinder,thr=0.25)

                    #cv2.imwrite('test_0.jpeg', (minutiae_cylinder[:, :, 0:3]) * 255)
                    #cv2.imwrite('test_1.jpeg', (minutiae_cylinder[:, :, 3:6]) * 255)
                    #cv2.imwrite('test_2.jpeg', (minutiae_cylinder[:, :, 6:9]) * 255)
                    #cv2.imwrite('test_3.jpeg', (minutiae_cylinder[:, :, 9:12]) * 255)
                    #prepare_data.show_features(img, minutiae, fname=os.path.basename(file)[:-4] +'.jpeg')

                    minutiae = prepare_data.refine_minutiae(minutiae, dist_thr=10, ori_dist=np.pi / 4)
                    prepare_data.show_minutiae(img0, minutiae)
                    print n
Esempio n. 6
0
def minutiae_extraction_latent(model_path, sample_path, imgs, output_name='reconstruction/gen:0', block=True):
    imgs = glob.glob('/Data/Latent/DB/NIST27/image/' + '*.bmp')

    minu_files = glob.glob('/Data/Latent/DB/ManualInformation/NIST27/ManMinu/*.txt')
    minu_files.sort()
    imgs.sort()

    import os
    if not os.path.isdir(sample_path):
        os.makedirs(sample_path)

    weight = get_weights(opt.SHAPE, opt.SHAPE, 12)
    with tf.Graph().as_default():

        with TowerContext('', is_training=False):
            with tf.Session() as sess:
                is_training = get_current_tower_context().is_training
                load_model(model_path)
                images_placeholder = tf.get_default_graph().get_tensor_by_name('QueueInput/input_deque:0')  # sub:0
                minutiae_cylinder_placeholder = tf.get_default_graph().get_tensor_by_name(output_name)
                for k, file in enumerate(imgs):
                    print file
                    img = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
                    u, texture = LP.FastCartoonTexture(img)
                    img = texture / 128.0 - 1

                    h, w = img.shape
                    x = []
                    y = []
                    nrof_samples = len(range(0, h, opt.SHAPE // 2)) * len(range(0, w, opt.SHAPE // 2))
                    patches = np.zeros((nrof_samples, opt.SHAPE, opt.SHAPE, 1))
                    n = 0
                    for i in range(0, h - opt.SHAPE + 1, opt.SHAPE // 2):

                        for j in range(0, w - opt.SHAPE + 1, opt.SHAPE // 2):
                            print j
                            patch = img[i:i + opt.SHAPE, j:j + opt.SHAPE, np.newaxis]
                            x.append(j)
                            y.append(i)
                            patches[n, :, :, :] = patch
                            n = n + 1
                        # print x[-1]
                    feed_dict = {images_placeholder: patches}
                    minutiae_cylinder_array = sess.run(minutiae_cylinder_placeholder, feed_dict=feed_dict)

                    minutiae_cylinder = np.zeros((h, w, 12))
                    minutiae_cylinder_array[:, -10:, :, :] = 0
                    minutiae_cylinder_array[:, :10, :, :] = 0
                    minutiae_cylinder_array[:, :, -10:, :] = 0
                    minutiae_cylinder_array[:, :, 10, :] = 0
                    for i in range(n):
                        minutiae_cylinder[y[i]:y[i] + opt.SHAPE, x[i]:x[i] + opt.SHAPE, :] = minutiae_cylinder[y[i]
                            :y[i] + opt.SHAPE, x[i]:x[i] + opt.SHAPE, :] + minutiae_cylinder_array[i] * weight
                    minutiae = prepare_data.get_minutiae_from_cylinder(minutiae_cylinder, thr=0.05)

                    minutiae = prepare_data.refine_minutiae(minutiae, dist_thr=10, ori_dist=np.pi / 4)

                    minutiae_sets = []
                    minutiae_sets.append(minutiae)

                    manu_minutiae = np.loadtxt(minu_files[k])
                    manu_minutiae[:, 2] = manu_minutiae[:, 2] / 180 * np.pi
                    minutiae_sets.append(manu_minutiae)

                    fname = sample_path + os.path.basename(file)[:-4] + '.jpeg'
                    prepare_data.show_minutiae_sets(img, minutiae_sets, ROI=None, fname=fname, block=block)
                    fname = sample_path + os.path.basename(file)[:-4] + '.txt'
                    np.savetxt(fname, minutiae_sets[0])
                    print(n)