none
Are there any (simple) methods/libraries to recognize similar pictures using C# code? RRS feed

  • Question

  • Not sure if it's possible to do this without referencing a large framework library.

    My first app downloads Bing daily pictures of 10 cultures. The problem is that most of the time the pictures of several cultures are only slightly different. This will create an illusion for end users that the app downloads many duplicate pictures.

    I wonder if there are any small and simple and ready-to-use C# frameworks/libraries that enable me to compare pictures to test if they are very similar, e.g., by 98%. Thanks.


    Ignorance is blissful

    Monday, October 16, 2017 3:53 PM

Answers

  • Hello Neo,

    Image recognition is a subject that more relating to artificial intelligence.For your situation.The easiest and simplest algorithm is just to do something as below.

    scale to something small, like 64x64 or 32x32, disregard aspect ratio, use a combining scaling algorithm instead of nearest pixel.A combining scaling algorithm is one that when scaling 10 pixels down to one will do it using a function that takes the color of all those 10 pixels and combines them into one.Can be done with algorithms like averaging, mean-value, or more complex ones like bicubic splines.Then calculate the mean distance pixel-by-pixel between the two images.

    If you need much more advanced algorithms,There are some options.

    1.Peak signal-to-noise ratio.
    https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio


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

    3.features2d calculate.
    https://docs.opencv.org/2.4/modules/features2d/doc/features2d.html

    Sincerely,
    Neil Hu

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Neo the 1 Tuesday, October 17, 2017 3:17 PM
    Tuesday, October 17, 2017 10:50 AM
    Moderator

All replies

  • Hi Neo,

    Welcome to the MSDN forum.

    Refer to your description, your issue is about the development and our forum is to discuss the VS IDE. What’s your application type? Like WPF, UWP or others, I will help you move it to the appropriate forum to seek for a better support and that will also helpful for you to quickly solve your question, thank you for your understanding.

    Meanwhile, I found some discussions about compare two images as below, and hope it helpful:

    Algorithm to compare two images in C#

    Comparing Two Images in C#

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, October 17, 2017 1:59 AM
  • I'm currently developing UWP applications, but I  think this question is essentially not tied to UWP. How about a forum of C# development?

    Ignorance is blissful

    Tuesday, October 17, 2017 4:38 AM
  • I already read the two links before I post this question. The algorithms provided in the two articles are too simple and do not meet my scenario. My need is to compare for similarity, not by 'being identical'. The reason is that two Bing daily pictures may only differ by watermarks that are in different language.

    Ignorance is blissful

    Tuesday, October 17, 2017 4:40 AM
  • Hi Neo,

    Thank you for your update.

    I will help you move this thread to the C# forum to seek for a better support, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, October 17, 2017 6:17 AM
  • Hello Neo,

    Image recognition is a subject that more relating to artificial intelligence.For your situation.The easiest and simplest algorithm is just to do something as below.

    scale to something small, like 64x64 or 32x32, disregard aspect ratio, use a combining scaling algorithm instead of nearest pixel.A combining scaling algorithm is one that when scaling 10 pixels down to one will do it using a function that takes the color of all those 10 pixels and combines them into one.Can be done with algorithms like averaging, mean-value, or more complex ones like bicubic splines.Then calculate the mean distance pixel-by-pixel between the two images.

    If you need much more advanced algorithms,There are some options.

    1.Peak signal-to-noise ratio.
    https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio


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

    3.features2d calculate.
    https://docs.opencv.org/2.4/modules/features2d/doc/features2d.html

    Sincerely,
    Neil Hu

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Neo the 1 Tuesday, October 17, 2017 3:17 PM
    Tuesday, October 17, 2017 10:50 AM
    Moderator
  • Hi Neo,

    You could look into follow blog post where it explains some of the image library you can uuse in .NET. Hope this will help you.

    .NET Core Image Processing


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Tuesday, October 17, 2017 11:29 AM
    Moderator
  • Thanks for the many links. It seems the topic is too complicated for my current need, I won't incorporate this feature into my app for now.

    Ignorance is blissful

    Tuesday, October 17, 2017 3:18 PM