سؤال

أحتاج خوارزمية التي تحدد ما إذا كان اثنين من الصور متشابهة تسلم على أنماط مماثلة من لون, سطوع, شكل الخ..قد تحتاج بعض المؤشرات على ما معلمات الدماغ البشري يستخدم 'تصنيف' صور...

لقد بحثت في هوسدورف على أساس مطابقة ولكن يبدو أساسا مطابقة تتحول الكائنات وأنماط الشكل.

هل كانت مفيدة؟

المحلول

لقد فعلت شيئا من هذا القبيل, من خلال تحليل الصور في التواقيع باستخدام تحويل المويجات.

توجهي إلى اختيار أهم n معاملات من كل حولت القناة ، وتسجيل مواقعها.وقد تم ذلك من خلال فرز قائمة (السلطة والموقع) الصفوف وفقا abs(السلطة).صور مماثلة سوف أوجه تشابه في أنه سيكون لديهم كبيرة معاملات في نفس الأماكن.

لقد وجدت أنه من الأفضل أن تتحول الصورة إلى YUV تنسيق فعال يسمح لك الوزن التشابه في الشكل (Y قناة) لون (الأشعة فوق البنفسجية قنوات).

يمكنك العثور على تنفيذ ما سبق في mactorii, والتي للأسف لم يعمل على قدر ما ينبغي أن يكون :-)

طريقة أخرى ، والتي بعض أصدقائي قد استخدمت مع نتائج جيدة بشكل مدهش, هو ببساطة تغيير حجم الصور الخاصة بك إلى أسفل القول ، 4x4 بكسل وتخزين التي تم التوقيع الخاص بك.كيف مماثل 2 الصور يمكن وسجل لنقل الحوسبة المسافة مانهاتن بين 2 الصور باستخدام المقابلة بكسل.ليس لدي تفاصيل عن كيفية إجراء تغيير الحجم, لذلك قد تضطر للعب مع خوارزميات مختلفة المتاحة لأداء هذه المهمة إلى العثور على واحد الذي هو مناسبة.

نصائح أخرى

pHash قد تهمك.

الإدراك الحسي تجزئة n.بصمة صوت أو فيديو أو صورة الملف رياضيا على أساس الصوت أو المحتوى المرئي الواردة في.على عكس الوظائف تجزئة التشفير التي تعتمد على الكم الهائل تأثير التغييرات الصغيرة في المدخلات تؤدي إلى تغييرات جذرية في الإخراج ، الإدراكية التجزئة "لا" إلى آخر إذا كان المدخلات بصريا أو auditorily مماثلة.

لقد استعملت نخل إلى إعادة اكتشاف te نفس الكائن في صور مختلفة.انها حقا قوية ولكن معقدة نوعا ما, و قد يكون مبالغة.إذا كان من المفترض أن تكون الصور جميلة مماثلة بعض المعلمات بسيطة على أساس الفرق بين الصورتين يمكن أن أقول لكم قليلا جدا.بعض المؤشرات:

  • تطبيع الصور أيجعل متوسط سطوع كل الصور نفس طريق حساب متوسط سطوع كل وتوسيع ألمع أسفل وفقا التموينية (لتجنب لقطة على أعلى مستوى)) لا سيما إذا كنت أكثر اهتماما في الشكل من اللون.
  • مجموع فرق اللون على تطبيع صورة لكل قناة.
  • العثور على حواف الصور و قياس المسافة بين حافة بكسل في كل من الصور.(الشكل)
  • تقسيم الصور في مجموعة منفصلة المناطق مقارنة متوسط لون كل منطقة.
  • عتبة الصور في واحد (أو مجموعة) المستوى(s) احسب عدد بكسل حيث الناتجة أسود/أبيض تختلف الصور.

هل يمكن استخدام الإدراك الحسي صورة مهرجان دبي السينمائي الدولي

انها أداة سطر الأوامر يقارن بين الصورتين باستخدام الإدراك الحسي متري.أي أنه يستخدم النموذج الحسابي النظام البصري الإنسان لتحديد ما إذا كان الصورتين مختلفة بصريا ، لذلك تغييرات طفيفة في بكسل يتم تجاهل.بالإضافة إلى أنه يقلل بشكل كبير من عدد من ايجابيات كاذبة الناجمة عن الاختلافات في الجيل رقم عشوائي, نظام التشغيل أو الجهاز العمارة الخلافات.

انها مشكلة صعبة!ذلك يعتمد على مدى دقة تحتاج إلى أن تكون, و ذلك يعتمد على أي نوع من الصور كنت تعمل مع.يمكنك استخدام رسوم بيانية لمقارنة الألوان ، ولكن من الواضح أنه لا يأخذ بعين الاعتبار التوزيع المكاني تلك الألوان في الصور (أيالأشكال).الكشف عن الحافة تليها نوع من التقسيم (أيتنتقي الأشكال) يمكن أن توفر نمط مطابقة ضد آخر صورة.يمكنك استخدام coocurence المصفوفات مقارنة القوام ، من خلال النظر في الصور المصفوفات من القيم بكسل ، مقارنة هذه المصفوفات.هناك بعض الكتب الجيدة هناك على صورة مطابقة رؤية الجهاز -- البحث في الأمازون سوف تجد بعض.

ويساعد هذا الأمل!

مختبري اللازمة لحل هذه المشكلة أيضا و كنا Tensorflow.هنا التطبيق الكامل تنفيذ لتصور صورة التشابه.

للحصول على البرنامج التعليمي على vectorizing صور التشابه حساب, تحقق هذه الصفحة.هنا هو بيثون (مرة أخرى ، راجع بوست كامل سير العمل):

from __future__ import absolute_import, division, print_function

"""

This is a modification of the classify_images.py
script in Tensorflow. The original script produces
string labels for input images (e.g. you input a picture
of a cat and the script returns the string "cat"); this
modification reads in a directory of images and 
generates a vector representation of the image using
the penultimate layer of neural network weights.

Usage: python classify_images.py "../image_dir/*.jpg"

"""

# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

"""Simple image classification with Inception.

Run image classification with Inception trained on ImageNet 2012 Challenge data
set.

This program creates a graph from a saved GraphDef protocol buffer,
and runs inference on an input JPEG image. It outputs human readable
strings of the top 5 predictions along with their probabilities.

Change the --image_file argument to any jpg image to compute a
classification of that image.

Please see the tutorial and website for a detailed description of how
to use this script to perform image recognition.

https://tensorflow.org/tutorials/image_recognition/
"""

import os.path
import re
import sys
import tarfile
import glob
import json
import psutil
from collections import defaultdict
import numpy as np
from six.moves import urllib
import tensorflow as tf

FLAGS = tf.app.flags.FLAGS

# classify_image_graph_def.pb:
#   Binary representation of the GraphDef protocol buffer.
# imagenet_synset_to_human_label_map.txt:
#   Map from synset ID to a human readable string.
# imagenet_2012_challenge_label_map_proto.pbtxt:
#   Text representation of a protocol buffer mapping a label to synset ID.
tf.app.flags.DEFINE_string(
    'model_dir', '/tmp/imagenet',
    """Path to classify_image_graph_def.pb, """
    """imagenet_synset_to_human_label_map.txt, and """
    """imagenet_2012_challenge_label_map_proto.pbtxt.""")
tf.app.flags.DEFINE_string('image_file', '',
                           """Absolute path to image file.""")
tf.app.flags.DEFINE_integer('num_top_predictions', 5,
                            """Display this many predictions.""")

# pylint: disable=line-too-long
DATA_URL = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'
# pylint: enable=line-too-long


class NodeLookup(object):
  """Converts integer node ID's to human readable labels."""

  def __init__(self,
               label_lookup_path=None,
               uid_lookup_path=None):
    if not label_lookup_path:
      label_lookup_path = os.path.join(
          FLAGS.model_dir, 'imagenet_2012_challenge_label_map_proto.pbtxt')
    if not uid_lookup_path:
      uid_lookup_path = os.path.join(
          FLAGS.model_dir, 'imagenet_synset_to_human_label_map.txt')
    self.node_lookup = self.load(label_lookup_path, uid_lookup_path)

  def load(self, label_lookup_path, uid_lookup_path):
    """Loads a human readable English name for each softmax node.

    Args:
      label_lookup_path: string UID to integer node ID.
      uid_lookup_path: string UID to human-readable string.

    Returns:
      dict from integer node ID to human-readable string.
    """
    if not tf.gfile.Exists(uid_lookup_path):
      tf.logging.fatal('File does not exist %s', uid_lookup_path)
    if not tf.gfile.Exists(label_lookup_path):
      tf.logging.fatal('File does not exist %s', label_lookup_path)

    # Loads mapping from string UID to human-readable string
    proto_as_ascii_lines = tf.gfile.GFile(uid_lookup_path).readlines()
    uid_to_human = {}
    p = re.compile(r'[n\d]*[ \S,]*')
    for line in proto_as_ascii_lines:
      parsed_items = p.findall(line)
      uid = parsed_items[0]
      human_string = parsed_items[2]
      uid_to_human[uid] = human_string

    # Loads mapping from string UID to integer node ID.
    node_id_to_uid = {}
    proto_as_ascii = tf.gfile.GFile(label_lookup_path).readlines()
    for line in proto_as_ascii:
      if line.startswith('  target_class:'):
        target_class = int(line.split(': ')[1])
      if line.startswith('  target_class_string:'):
        target_class_string = line.split(': ')[1]
        node_id_to_uid[target_class] = target_class_string[1:-2]

    # Loads the final mapping of integer node ID to human-readable string
    node_id_to_name = {}
    for key, val in node_id_to_uid.items():
      if val not in uid_to_human:
        tf.logging.fatal('Failed to locate: %s', val)
      name = uid_to_human[val]
      node_id_to_name[key] = name

    return node_id_to_name

  def id_to_string(self, node_id):
    if node_id not in self.node_lookup:
      return ''
    return self.node_lookup[node_id]


def create_graph():
  """Creates a graph from saved GraphDef file and returns a saver."""
  # Creates graph from saved graph_def.pb.
  with tf.gfile.FastGFile(os.path.join(
      FLAGS.model_dir, 'classify_image_graph_def.pb'), 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(graph_def, name='')


def run_inference_on_images(image_list, output_dir):
  """Runs inference on an image list.

  Args:
    image_list: a list of images.
    output_dir: the directory in which image vectors will be saved

  Returns:
    image_to_labels: a dictionary with image file keys and predicted
      text label values
  """
  image_to_labels = defaultdict(list)

  create_graph()

  with tf.Session() as sess:
    # Some useful tensors:
    # 'softmax:0': A tensor containing the normalized prediction across
    #   1000 labels.
    # 'pool_3:0': A tensor containing the next-to-last layer containing 2048
    #   float description of the image.
    # 'DecodeJpeg/contents:0': A tensor containing a string providing JPEG
    #   encoding of the image.
    # Runs the softmax tensor by feeding the image_data as input to the graph.
    softmax_tensor = sess.graph.get_tensor_by_name('softmax:0')

    for image_index, image in enumerate(image_list):
      try:
        print("parsing", image_index, image, "\n")
        if not tf.gfile.Exists(image):
          tf.logging.fatal('File does not exist %s', image)

        with tf.gfile.FastGFile(image, 'rb') as f:
          image_data =  f.read()

          predictions = sess.run(softmax_tensor,
                          {'DecodeJpeg/contents:0': image_data})

          predictions = np.squeeze(predictions)

          ###
          # Get penultimate layer weights
          ###

          feature_tensor = sess.graph.get_tensor_by_name('pool_3:0')
          feature_set = sess.run(feature_tensor,
                          {'DecodeJpeg/contents:0': image_data})
          feature_vector = np.squeeze(feature_set)        
          outfile_name = os.path.basename(image) + ".npz"
          out_path = os.path.join(output_dir, outfile_name)
          np.savetxt(out_path, feature_vector, delimiter=',')

          # Creates node ID --> English string lookup.
          node_lookup = NodeLookup()

          top_k = predictions.argsort()[-FLAGS.num_top_predictions:][::-1]
          for node_id in top_k:
            human_string = node_lookup.id_to_string(node_id)
            score = predictions[node_id]
            print("results for", image)
            print('%s (score = %.5f)' % (human_string, score))
            print("\n")

            image_to_labels[image].append(
              {
                "labels": human_string,
                "score": str(score)
              }
            )

        # close the open file handlers
        proc = psutil.Process()
        open_files = proc.open_files()

        for open_file in open_files:
          file_handler = getattr(open_file, "fd")
          os.close(file_handler)
      except:
        print('could not process image index',image_index,'image', image)

  return image_to_labels


def maybe_download_and_extract():
  """Download and extract model tar file."""
  dest_directory = FLAGS.model_dir
  if not os.path.exists(dest_directory):
    os.makedirs(dest_directory)
  filename = DATA_URL.split('/')[-1]
  filepath = os.path.join(dest_directory, filename)
  if not os.path.exists(filepath):
    def _progress(count, block_size, total_size):
      sys.stdout.write('\r>> Downloading %s %.1f%%' % (
          filename, float(count * block_size) / float(total_size) * 100.0))
      sys.stdout.flush()
    filepath, _ = urllib.request.urlretrieve(DATA_URL, filepath, _progress)
    print()
    statinfo = os.stat(filepath)
    print('Succesfully downloaded', filename, statinfo.st_size, 'bytes.')
  tarfile.open(filepath, 'r:gz').extractall(dest_directory)


def main(_):
  maybe_download_and_extract()
  if len(sys.argv) < 2:
    print("please provide a glob path to one or more images, e.g.")
    print("python classify_image_modified.py '../cats/*.jpg'")
    sys.exit()

  else:
    output_dir = "image_vectors"
    if not os.path.exists(output_dir):
      os.makedirs(output_dir)

    images = glob.glob(sys.argv[1])
    image_to_labels = run_inference_on_images(images, output_dir)

    with open("image_to_labels.json", "w") as img_to_labels_out:
      json.dump(image_to_labels, img_to_labels_out)

    print("all done")
if __name__ == '__main__':
  tf.app.run()

بعض الصور برنامج التعرف على الحلول في الواقع لا بحتة الخوارزمية ولكن الاستفادة من الشبكة العصبية مفهوم بدلا من ذلك.تحقق من http://en.wikipedia.org/wiki/Artificial_neural_network و وهي NeuronDotNet التي تضم أيضا مثيرة للاهتمام العينات: http://neurondotnet.freehostia.com/index.html

هناك البحوث المتعلقة باستخدام Kohonen الشبكات العصبية/الذاتي تنظيم الخرائط

أكثر الأنظمة الأكاديمية (جوجل PicSOM ) أو أقل الأكاديمية
( http://www.generation5.org/content/2004/aiSomPic.asp , (ربما غير مناسب جميع بيئات العمل)) العروض موجودة.

حساب مجموع مربعات الفروق بكسل اللون قيم جذريا تحجيم الإصدار (على سبيل المثال:6x6 بكسل) يعمل بشكل جيد.الصور متطابقة العائد 0, صور مماثلة العائد أعداد صغيرة, صور مختلفة العائد الكبيرة.

بقية اللاعبين فوق فكرة اقتحام YUV الأولى يبدو مثيرا - حين فكرتي يعمل كبيرة, أريد الصور على حسابها على "مختلفة" حتى أنه ينتج نتيجة صحيحة - حتى من وجهة نظر وcolourblind المراقب.

هذا يبدو وكأنه مشكلة في الرؤية.قد ترغب في النظر في التكيف تعزيز فضلا عن الحروق خط استخراج الخوارزمية.مفاهيم في هذين ينبغي أن تساعد في معالجة هذه المشكلة.الكشف عن الحافة حتى أسهل مكان للبدء إذا كنت جديدا على الرؤية الخوارزميات ، كما يشرح الأساسيات.

بقدر ما معايير التصنيف:

  • الألوان & موقع (التدرج حساب الرسم البياني من الألوان)
  • الواردة الأشكال (ادا.تعزيز/التدريب للكشف عن الأشكال)

اعتمادا على مدى دقة النتائج التي تحتاج إليها ، يمكنك ببساطة كسر الصور في n x n بكسل كتل و تحليلها.إذا كنت تحصل على نتائج مختلفة في المربع الأول لا يمكنك التوقف عن المعالجة ، مما أدى إلى بعض التحسينات الأداء.

تحليل المربعات يمكنك على سبيل المثال الحصول على مجموع قيم الألوان.

هل يمكن إجراء نوع من كتلة مطابقة تقدير الحركة بين الصورتين و تدبير المبلغ الاجمالي من المخلفات و ناقلات الحركة التكاليف (مثل الكثير من شأنها أن تساعد في ترميز الفيديو).هذا من شأنه أن يعوض عن الحركة ؛ للحصول على نقاط المكافأة ، هل أفيني-التحول تقدير الحركة (يعوض بتكبير وتمتد مماثلة).يمكن أن تفعل أيضا تداخل كتل أو التدفق البصري.

كما يمر أولا ، يمكنك محاولة استخدام اللون في رسوم بيانية.ومع ذلك, كنت حقا بحاجة إلى تضييق المشكلة المجال.Generic صورة مطابقة مشكلة صعبة جدا.

لقد وجدت هذه المادة مفيدة جدا في شرح كيف يعمل:

http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html

الاعتذار عن الانضمام إلى وقت متأخر في المناقشة.

يمكننا حتى استخدام الجرم السماوي منهجية للكشف عن ميزات مشابهة النقاط بين الصورتين.الرابط التالي يعطي التنفيذ المباشر من الجرم السماوي في بايثون

http://scikit-image.org/docs/dev/auto_examples/plot_orb.html

حتى بنسف وقد حصلت التنفيذ المباشر من الجرم السماوي.إذا مزيد من المعلومات اتبع البحث المقالة أدناه.

https://www.researchgate.net/publication/292157133_Image_Matching_Using_SIFT_SURF_BRIEF_and_ORB_Performance_Comparison_for_Distorted_Images

هناك بعض إجابات جيدة في موضوع آخر على هذا, ولكن أنا أتساءل عما إذا كان هناك شيء تنطوي على التحليل الطيفي أن تعمل ؟ I. e., كسر الصورة أسفل إلى مرحلة السعة المعلومات ومقارنة تلك.هذا قد تجنب بعض القضايا مع الاقتصاص ، والتحول شدة الخلافات.على كل حال هذا مجرد لي المضاربة لأن هذا يبدو وكأنه مشكلة مثيرة للاهتمام.إذا بحثت http://scholar.google.com أنا متأكد من أنك يمكن أن يأتي مع عدة ورقات على هذا.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top