Finding an object in an array

  • Thread starter Thread starter Haxx0rm4ster
  • Start date Start date
  • Tags Tags
    Array
Click For Summary
SUMMARY

This discussion focuses on efficiently identifying an "object" within a vector of 64 cells, where each cell can hold a value from 0 to 7, representing colors. An "object" is defined as a sequence of 25 to 45 consecutive non-zero cells of the same value, with the stipulation that no two consecutive cells can overlap. The user seeks an efficient algorithm suitable for MIPS assembly language, emphasizing minimal instruction usage. The proposed approach involves checking specific cell groups for equal values to detect potential objects while avoiding false positives.

PREREQUISITES
  • Understanding of MIPS assembly language programming
  • Knowledge of data structures, specifically arrays and vectors
  • Familiarity with algorithm design and efficiency considerations
  • Basic concepts of color representation in programming (0-7 for colors)
NEXT STEPS
  • Research efficient algorithms for detecting sequences in arrays
  • Explore MIPS assembly optimization techniques for reducing instruction count
  • Learn about dynamic programming approaches to improve algorithm accuracy
  • Investigate methods to minimize false positives in pattern recognition
USEFUL FOR

Software developers, particularly those working with low-level programming in MIPS, algorithm designers, and anyone involved in pattern recognition within data structures.

Haxx0rm4ster
Messages
37
Reaction score
0
Finding an "object" in an array

Say I have a vector of 64 cells. Each cell can have a value of 0-7 (each represents a color). Inside this vector I may have an "object" which would be defined as a set of consecutive non-zero (zero=black) cells with the same value. The object is no longer than 45 consecutive cells and no smaller than 25. This object however might have some of its parts overlapped by another one
like in the following picture:

http://img54.imageshack.us/img54/8366/captureu.png

However the object does not have 2 consecutive cells that are overlapped.
What'd be an efficient way to find out whether there IS an object in the vector or not?

It doesn't have to be completely accurate, but the more accurate and efficient, the better.
I thought of getting 4 cells from 2 areas in the picture say cells # 20 21 22 23 and 40 41 42 43 then if cells 21,22 or 21,23 or 20,22 are of equal value (and not black/0) there could be an "object." If no object was identified in that first area, then I'd check the second one.

However if for example 20,22 are the same color, it'll raise a false alarm even though the rest of the cells in the entire vector maybe black.

And the huge catch, is that this is part of a bigger project I have to code in MIPS, so the algorithm would have to be assembly friendly, and take as few instructions as possible.

This is my current MIPS assembly implementation. Maybe if I can't get help with a better algorithm, I may be advised on how to implement it more efficiently. I'm focusing more on the dynamic instruction length of the algorithm than anything else.

http://pastebin.com/d75241b9e
 
Last edited by a moderator:
Technology news on Phys.org


As they say, DISREGARD THAT, I SUCK ...

What an incredible epiphany. I guess I just needed some rest.
A valid row would be characterized by two consecutive non-zero cells that would be either in the areas from cells 20-25 or 40-45.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 30 ·
2
Replies
30
Views
6K
  • · Replies 7 ·
Replies
7
Views
4K
Replies
13
Views
3K
Replies
3
Views
2K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
25K
  • · Replies 11 ·
Replies
11
Views
2K