Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could increment the threshold until you find a square, and use a 2D FSM to detect the square.</p> <p>This will produce a match in <code>O(width * height * bpp)</code> (binary search on the lowest possible threshold, assuming a power-of-two range):</p> <pre><code>- set threshold to its maximum value - for every bit of the threshold - clear the bit in the threshold - if there is a match - record the set of matches as a result - else - set the bit - if there is no record, then the threshold is its maximum. to detect a square: - for every pixel: - if the pixel is too bright, set its line-len to 0 - else if it's the first column, set its line-len to 1 - else set its line-len to the line-len of the pixel to the left, plus one - if the pixel line-len is less than N, set its rect-len to 0 - else if it's the first row, set its rect-len to 1 - else set its rect-len to the rect-len of the pixel above, plus one - if the rect-len is at least N, record a match. </code></pre> <p><code>line-len</code> represents the number of consecutive pixels that are dark enough.</p> <p><code>rect-len</code> represents the number of consecutive rows of dark pixels that are long enough and aligned.</p> <p>For video-capture, replace the binary search by a linear search from the threshold for the previous frame.</p> <p>Obviously, you can't get better than <code>theta(width/N * height/N)</code> best case (as you'll have to rule out every possible position for a darker square) and the bit depth can be assumed constant, so this algorithm is asymptotically optimal for a fixed N. It's probably asymptotically optimal for N as a part of the input as well, as (intuitively) you have to consider almost every pixel in the average case.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload