Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:09:23+00:00 2026-05-28T00:09:23+00:00

I have an array of float values which could be interpreted as a grayscale

  • 0

I have an array of float values which could be interpreted as a grayscale image or a 3D surface (heightmap).
For instance it may be a 10×10 array like this :

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 4 0 9 0 0 0 0 0
0 0 0 0 0 0 0 0 3 0
0 8 0 0 0 0 0 0 0 0
0 0 0 6 0 2 8 7 0 0
0 0 0 0 0 3 5 5 0 0
0 0 0 0 0 6 2 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

I’m looking for a Java library (or efficient algorithm) to detect the presence and location of one (or more) pattern similar to a reference pattern, for instance I want to obtain the location (5,5) as a result no matter I was looking for :

2 8 7
3 5 5
6 2 1

or :

3 8 6
3 6 5
5 2 3

Any idea ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:09:24+00:00Added an answer on May 28, 2026 at 12:09 am

    I dont know of any Java libraries, but I would figure it wouldn’t be too hard to program. This problem can be seen as a derivative of the sub-string problem, except you don’t have a linear string. Here’s some Java-ish pseudo-code that is probably pretty close.

    for(int x = 0; x < heightmap.width(); ++x)
        for(int y = 0; y < heightmap.height(); ++y)
            if(find_pattern(x, y))
                // YAY! pattern starts at (x, y)
    
    // start at (x, y) and find an exact match
    boolean find_pattern(int x, int y)
    {
          for(int xx = 0; xx < pattern.width(); ++x)
              for(int yy = 0; yy < pattern.width(); ++x)
                  if(heightmap[x + xx][y + yy] != pattern[xx][yy])
                      return false;
          return true; 
    }
    

    This will find an exact match. If you want something, say plus or minus 2, then you will need a little extra logic in find_pattern() instead of the != comparison.

    There may be some other algorithms that run better. This is probably the simplest to program. Complexity wise this runs in O(n^2 * m^2): given n is the width and height of the heightmap, and m is the width and height of the pattern.

    NOTE: this does not do boundary checking!

    If you implement boundary checking, it will cut down on the number of comparisons needed since obviously the above pattern cannot start in the two right-most columns of the height map. Interestingly enough, when you have boundary checking, the complexity goes to O(n^2) as the ratio n:m goes to either 1:1 or 0:1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java array defined already e.g. float[] values = new float[3]; I
I have a 1-dimensional float array of root mean square values, each calculated with
I essentially have an array of values like this: 0.25, 0.24, 0.27, 0.26, 0.29,
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
An array is defined of assumed elements like I have array like String[] strArray
Have an array of chars like char members[255]. How can I empty it completely
I have an application which reads in gridded coordinate data with values (i.e. lat,
I have the following code which does nothing but reading some values from a
I have a web service method which i'd like to return multiple rows from
we have one class which has one float[] and one int[] . Sometimes the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.