## 'Sliced' Subwindow Search: a Sublinear-complexity Solution to the Maximum Rectangle Problem

Max Reuter * 1,2 , Gheorghe-Teodor Bercea †1 , Liana Fong 1

1

IBM T.J. Watson Research Center, Yorktown Heights, NY 2 Department of Computer Science and Engineering, Michigan State University

## Abstract

Considering a 2D matrix of positive and negative numbers, how might one draw a rectangle within it whose contents sum higher than all other rectangles'? This fundamental problem, commonly known the maximum rectangle problem or subwindow search, spans many computational domains. Yet, the problem has not been solved without demanding computational resources at least linearly proportional to the size of the matrix. In this work, we present a new approach to the problem which achieves sublinear time and memory complexities by interpolating between a small amount of equidistant sections of the matrix. Applied to natural images, our solution outperforms the state-ofthe-art by achieving an 11x increase in speed and memory efficiency at 99% comparative accuracy. In general, our solution outperforms existing solutions when matrices are sufficiently large and a marginal decrease in accuracy is acceptable, such as in many problems involving natural images. As such, it is well-suited for real-time application and in a variety of computationally hard instances of the maximum rectangle problem.

## 1. Introduction

The problem of locating the maximal-sum rectangle in a 2D matrix spans a variety of disciplines, including computer vision [1, 2], data mining [5], data analysis [4], pattern matching [6], computational theory [9], and more [13, 12, 11]. Known as the max-weight rectangle problem in its purest form, the problem's definition considers n × m matrices. As in many existing works, we will instead consider inputs of n × n matrices without much loss of generality in practice, with O N ( ) = O n ( 2 ) as the definition of linear complexity.

* reuterm1@msu.edu

† gheorghe-teod.bercea@ibm.com

Figure 1. Matrix slices used to guide Sliced Subwindow Search , the number of which are determined by a user-chosen function of the matrix size. Only this subset of the matrix is read during search, drastically reducing running time and memory footprint.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-6e9f6425-eef8-4455-858e-540c2045a4bd.jpg)

Despite decades of its study, even approximate solutions to the max-weight rectangle problem require substantial computational resources [1, 3, 2, 9]. The problem's leading and long-standing solutions are comprised of an exact algorithm which runs in O n ( 3 ) time [3], an exact algorithm which runs in O n ( 2 ) expected time to O n ( 4 ) worstcase time [2], and an approximate algorithm which runs in O n ( 2 ) expected time to O n ( 3 ) worst-case time [1]. In this work, we will present an algorithm which achieves sublinear time: O ( n 2 f ( n ) ) , with f ( n ) a user-chosen function of the matrix's size (see Figure 1).

## 1.1. Subwindow Search for Object Localization

Object localization invokes the maximum rectangle problem by extracting image features into a 2D matrix of the same dimensions as the image, corresponding to 'pixels of interest'. Then, subwindow search is used to locate a highly positive section of this feature matrix, yielding a

Table 1. Expected complexities for the max-weight rectangle problem on n × n matrices. Note that A-ESS runs 900x faster than ESS on average in practice [1].

| Algorithm             | Accuracy                            | Time                                            | Memory                                          |
|-----------------------|-------------------------------------|-------------------------------------------------|-------------------------------------------------|
| Bentley ESS A-ESS SSS | Exact Exact Approximate Approximate | O ( n 3 ) O ( n 2 ) O ( n 2 ) O ( n 2 f ( n ) ) | O ( n 2 ) O ( n 2 ) O ( n 2 ) O ( n 2 f ( n ) ) |

bounding box around the 'area of most interest'. Critically, in all current solutions to the maximum rectangle problem, any similarity among nearby elements of the input matrix is not exploited. In this work, we focus on the problem of object localization, which allows for a clear and highly practical demonstration of the advantage of doing so.

## 1.2. Contributions

We present Sliced Subwindow Search ( SSS ), an approximation algorithm for the max-weight rectangle problem which scales considerably more gracefully than existing solutions (see Table 1). Our algorithm leverages similarity among nearby matrix values via equidistant sampling, allowing for inferences to be made about the unsampled data without dedicating additional computational resources to it. We also show advantageous performance of our algorithm on sufficiently large matrices which exhibit no nearby-element similarity. While sampling is a commontechnique used to trade accuracy for speed across many problems, our novelty contribution lies in the non-trivial embedding of sampling as a concept within the max-weight rectangle problem's optimal subroutines.

In summary, we make the following contributions:

- · We present an approximate solution to the maximum rectangle problem which runs in sublinear time and memory, significantly reducing running time and memory usage compared to all existing solutions.
- · We evaluate our approach on the PASCAL VOC 2006 dataset and obtain an 11x increase in speed and memory efficiency over the state-of-the-art solution with 99% comparative accuracy.
- · We demonstrate that an increase in either the size or the nearby-element similarity of input matrices rapidly increases the relative performance of our solution.

## 2. Related Works

Formally, for an n × n matrix of positive and negative numbers, its maximum submatrix is that whose sum is largest among that of all possible submatrices. That is, for some n × n matrix M with x-axis indices 0 ≤ x &lt; n and yaxis indices 0 ≤ y &lt; n , the maximum submatrix with maximum sum S max and optimal bounds [( x , y 1 1 ) , ( x , y 2 2 )] with x 1 ≤ x 2 and y 1 ≤ y 2 is defined as:

$$S _ { m a x } \stackrel { \vartriangle } { = } \sum _ { x = x _ { 1 } } ^ { x _ { 2 } } \sum _ { y = y _ { 1 } } ^ { y _ { 2 } } M [ x, y ] \text{ \quad \ \ } ( 1 )$$

The max-weight rectangle problem can be trivially brute-forced by examining all possible n 4 submatrices and maximizing across them in O n ( 6 ) time ( O n ( 2 ) spent on each to sum their contents). This solution uses O (1) space and yields the globally optimal submatrix. In contrast to this solution, an approximation algorithm simply attempts to yield a globally optimal submatrix. In this work, we measure the quality of a given solution's approximated submatrix by calculating its area of overlap (more precisely, the intersection over union or IoU) with the global optimum.

## 2.1. Kadane's Algorithm: a Key Subroutine

At the core of all prominent solutions to the max-weight rectangle problem is Kadane's algorithm (1977) [3], a solution to the 1D maximum-subarray problem: a search for the subarray within an array whose sum is largest among that of all subarrays. Formally, for some array A of size n , its maximum subarray with maximum sum S max and optimal bounds [ x , x 1 2 ] for 0 ≤ x &lt; n with x 1 ≤ x 2 is defined as:

$$S _ { m a x } \stackrel { \triangle } { = } \sum _ { x = x _ { 1 } } ^ { x _ { 2 } } A [ x ] \text{ \quad \ \ } \text{(2)}$$

Kadane's algorithm is implemented as follows. First, it traverses the input array, collecting array elements until the running sum of the collection is negative, at which point it discards the collection and begins a new one. While traversing, it records intervals of the array corresponding to a collection whose sum is maximal among those it has seen thus far. Ultimately, when it reaches the end of the array, its record at that time describes the collection which had the globally maximum sum. It then returns the bounds and sum of that collection.

As Kadane's algorithm performs a constant number of calculations for each array element, its running time corresponds to the amount of time taken to traverse the array: O n ( ) . It uses space to store the running maximum sum and its boundaries, both of which are independent of the input size. Thus, its space complexity is O (1) .

## 2.2. Bentley's Algorithm: an Exact Solution

Bentley's algorithm (1984) [3] provides a O n ( 3 ) time and O n ( 2 ) space exact algorithm for the max-weight rectangle problem. It does so by examining all possible columnto-column pairs and aggregating the values between them into an array, which is then sent to Kadane's algorithm. The

returned column combination [ x , x ′ 1 ′ 2 ] with the maximum sum then describes the horizontal bounds of the globally optimal submatrix. Then, the optimal vertical [ y , y ′ 1 ′ 2 ] bounds are determined by a similar aggregation and maximization, but within these horizontal bounds .

As there are O n ( 2 ) [ x , x 1 2 ] column-to-column combinations in a given matrix, and applying Kadane's algorithm to each corresponding 1D aggregation costs O n ( ) time, the running time of Bentley's algorithm is O n ( 2 ) × O n ( ) = O n ( 3 ) . Crucially, the aggregation of a given column-to-column combination into a 1D array must be constant time to achieve this complexity. This can be accomplished with preprocessing: first computing the prefix sums of the matrix, allowing the sum between two points to be computed in O (1) time. This preprocessing takes O n ( 2 ) time and occupies O n ( 2 ) space, determining the algorithm's O n ( 2 ) space complexity.

## 2.3. Efficient Subwindow Search (ESS)

Efficient Subwindow Search (ESS) (2008) [2] is another exact solution which has utility in object localization by maximizing across a large class of classifier functions over all subimages. A branch-and-bound method, ESS guarantees a globally optimal solution in O n ( 2 ) expected time to O n ( 4 ) worst-case time using O n ( 2 ) expected space to O n ( 4 ) worst-case space. Its worst-case time on the PASCAL VOC 2006 dataset is measured to take 52x more time to compute than the average case of Bentley's O n ( 3 ) algorithm, and on average its running time on the dataset is 1.1x that of Bentley's algorithm [1], though it is more practical than Bentley's algorithm in different object detection and retrieval scenarios.

ESS examines disjoint subsets of the set of all possible submatrices in a best-first manner, noting the maximal quality in each subset. This allows for the discarding of many subset search spaces due to their maximal qualities being inadequate with respect to other previous states. The algorithm calculates integral images in preprocessing, costing O n ( 2 ) time and O n ( 2 ) space. In the worst case of ESS, all submatrices must be examined, of which there are O n ( 4 ) , resulting in the algorithm's worst-case time and space complexities.

## 2.4. Alternating Efficient Subwindow Search (A-ESS)

Alternating Efficient Subwindow Search (A-ESS) (2009) [1] is an approximation algorithm that runs in O n ( 2 ) expected time using O n ( 2 ) space, though its worst-case time is O n ( 3 ) . Like Bentley's algorithm, A-ESS begins by computing the horizontal and vertical prefix sums of the input matrix, requiring O n ( 2 ) time and space. It then initializes a candidate submatrix the size of the matrix itself. At each iteration, values along the horizontal bounds (not

Figure 2. Iterative refinement of bounds conducted by A-ESS and SSS. Note that not each iteration's bounding box need be strictly within bounds of the that of the previous iteration.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-34f7fd77-6a69-40e8-afa6-7de9b8764025.jpg)

exclusively those within both the horizontal and vertical bounds) are aggregated into a 1D array. Similarly, values along the vertical bounds are aggregated. Then, both of these 1D arrays are evaluated by Kadane's algorithm, using the returned bounds for the candidate submatrix in the next iteration. This iterative refinement process continues until a further iteration would cause a decrease in the sum of the values within the candidate bounding box (see Figure 2).

The score function used to determine the quality of a candidate bounding box and whether another iteration should take place is the difference between the maximum sums of the current iteration's 1D horizontal and vertical subarrays. This function is non-decreasing, and the optimal score is bounded by the sum of all the matrix's positive elements. Thus, the algorithm is convergent.

On the PASCAL VOC 2006 natural image dataset, it has been shown that the number of iterations in A-ESS' search loop is typically 3-6 [1], thus the expected computational complexity is determined by the upper bound of a constant number of loop iterations and any preprocessing. A loop iteration costs only O n ( ) time and O n ( ) space to aggregate values into 1D arrays, leveraging the prefix sum matrices. However, calculating the prefix sum matrices costs O n ( 2 ) time and O n ( 2 ) space, thus the algorithm's time complexity is typically dominated by this preprocessing. Finally, because there are O n ( 2 ) possible row and column intervals to search and an iteration costs O n ( ) time, the algorithm's worst-case time complexity is O n ( 2 ) × O n ( ) = O n ( 3 ) . As A-ESS is exceedingly effective in practice, we consider this the current state-of-the-art algorithm.

## 2.5. Other Solutions

An exact algorithm exists which is most useful when applied to large matrices with time complexity

O n ( 3 ( log log n log n ) 1 / 2 ) &lt; O n ( 3 ) [14]. However, matrices with n &lt; 1 000 000 , , cause the algorithm to perform less efficiently than Bentley's algorithm due to preprocessing overheads [1], and so it is commonly impractical.

A distributed exact solution of the problem's workload exists that allows it to be solved in O (log n ) time across O ( n 3 log n ) workers [15]. However, on the PASCAL VOC 2006 dataset, achieving this O (log n ) running time requires millions of workers, and achieving a running time competitive with ESS or A-ESS (on the order of O n ( 2 ) ) would still require dozens of workers.

## 3. Sliced Subwindow Search (SSS)

Our approach, which we call Sliced Subwindow Search or SSS, is an approximation algorithm that partially samples a given matrix rather than examining all of its elements (see Figure 1). The algorithm is similar to A-ESS in that it initializes a candidate bounding box that is the size of the matrix itself, then iteratively refines its bounds towards more desirable submatrices. However, it computes only parts of the horizontal and vertical prefix sums, computing only prefix sums of equidistant rows and columns at a stride length of some user-chosen f ( n ) . For example, given a matrix with 100 rows, a chosen f ( n ) = √ n = 10 , and an offset of f ( n ) 2 = 5 , rows 5 15 25 , , , . . . 85 95 , will have their horizontal prefix sums computed. Similarly, equidistant columns will have their prefix sums computed. The other rows and columns can be omitted as they will not be referenced during the search loop. Thus, the prefix sums occupy O ( n 2 f ( n ) ) space rather than A-ESS' O n ( 2 ) , determining the two algorithms' difference in memory complexity.

After the prefix sums have been computed, SSS initializes the candidate bounding box that is the size of the matrix itself, then begins a search loop similar to that of A-ESS'. First, it aggregates the columns within range [ x , x 1 2 ] into a 1D vertically-oriented array via summation. However, in contrast to A-ESS, not all columns are selected for aggregation. Only equidistant sections of the columns f ( n ) rows apart are written to the 1D array, referencing the previously computed partial horizontal prefix sum matrix, and the rest of the 1D array is populated with zeros. For example, given a matrix with 100 rows and f ( n ) = √ n = 10 and an offset of f ( n ) 2 = 5 , indices 5 15 25 , , , . . . 85 95 , of columns within range [ x , x 1 2 ] are sampled and have their sums written to the 1D array at indices 5 15 25 , , , . . . 85 95 , , respectively. Then, the 1D array with zeros at the indices where sampling was not done is sent to Kadane's algorithm which returns optimal bounds that serve as top and bottom boundaries [ y , y ′ 1 ′ 2 ] for the next iteration of the candidate submatrix. A similar process is repeated for the rows, obtaining new left and right [ x , x ′ 1 ′ 2 ] bounds using the partial vertical prefix sum matrix. [ x , x ′ 1 ′ 2 ] and [ y , y ′ 1 ′ 2 ] are then used to de-

## Algorithm 1 Sliced Subwindow Search (SSS)

Require:

n × n matrix M

Preprocessing: compute partial horizontal and sums P h and P v ;

prefix

$$\text{ad} \quad \text{Initialization: Set } ( x _ { 1 }, x _ { 2 } ) = ( y _ { 1 }, y _ { 2 } ) = ( 1, n ), g = 1,$$

I = 1;

while g &gt; 0 and I ≤ I cap do

- 1. Populate arrays a and b with zeros;
- 2. Compute a j [ ] = y 2 ∑ i = y 1 M i, j [ ] with j incrementing

by f ( n ) from 1 to n using P v ;

- 3. Apply Kadane's algorithm to a and find the optimal column interval [ x , x ′ 1 ′ 2 ] and the maximum s 1 ;

′

- 4. Compute b i [ ] = x 2 ∑ j = x ′ 1 M i, j [ ] with i incrementing

by f ( n ) from 1 to n using P h ;

- 5. Apply Kadane's algorithm to b and find the optimal row interval [ y , y ′ 1 ′ 2 ] and the maximum s ;
- 6. Set the gain g = s -s 1 ;
- 7. Increment the iteration count I = I +1 ;

end while fine the new candidate bounding box's boundaries, and the iterative refinement process continues. The previous iteration's maximum sum of the partially populated 1D array fed to Kadane's algorithm is compared to the current iteration's, and the program returns when the current iteration's sum is the smaller of the two values, indicating a likely decrease in the candidate bounding box's quality. See Algorithm 1 for the algorithm's pseudocode.

The search space contains O n ( 2 ) points, so if it is sampled every f ( n ) rows or columns via striding, O ( n 2 f ( n ) ) points will be examined. Given this and the employment of an iteration cap I cap (see Section 3.2), the algorithm runs in O ( n 2 f ( n ) ) time. Thus, if the size of the input O N ( ) = O n ( 2 ) is considered as the reference point for linearity, SSS is sublinear in its time and memory usage.

## 3.1. Convergence

Unlike A-ESS, SSS is not guaranteed to converge without the usage of an iteration cap due to its use of sampling. However, similar to A-ESS, the number of iterations needed to reach a high-quality bounding box is generally low. The looping case can be triggered by two edge cases: (1) the search is narrowed down to a 1-dimensional array that is not represented in the sampling, or (2) missing data due to sampling causes the horizontal and vertical searches to suggest to each other bounds whose contents the other cannot completely evaluate in a particularly problematic way. This can cause the objective function to falsely report that a search

iteration was profitable and that the search should continue. Wethus use I cap to limit the number of iterations performed during the search phase. Cases where this cap is reached result in very low accuracy, but are most common among small and random matrices, and their occurrence drops precipitously as matrices become larger and/or more spatially coherent.

## 3.2. Accuracy

Theoretical bounds and guarantees of SSS have limited practical use due to its data-dependent nature (partially inherited from A-ESS). In the best case, the sampled data is sufficient to inform a perfect, globally optimal bounding box (100% accuracy). In the worst case, the sampled data is insufficient (such as no meaningful data being sampled), resulting in a low-quality bounding box proposal (0% accuracy). Therefore, in general, no guarantees can be supplied, and certainly not without knowledge of the nature of the input data. In light of this, we provide a spatial coherence score (see Section 4.3.1) measuring the patterned nature of the input that, in our experiments across many types of data, is a strong predictor of SSS' accuracy.

## 4. Performance Evaluation

## 4.1. Experimental Setup

We first compare the runtime and accuracy of SSS to that of A-ESS on the localization of 10 object classes in the PASCAL VOC 2006 dataset on a Power 9 CPU, compiling our code with Clang version 8.0. The experiments were executed with exclusive access to the compute node. To ensure a fair comparison, we use the exact same A-ESS implementation as was used in its publication [1], which we obtained directly from the authors. We also compare SSS to A-ESS on the RGB color channels of (1) digital art, (2) a diverse set of high-resolution images, and (3) randomized matrices of various sizes.

## 4.2. Input Details

## 4.2.1 PASCAL VOC 2006

The images in the PASCAL dataset contain around 200,000 pixels. Object features of the images and are represented as sparse matrices which contain around n 2 = 16 000 , entries. The dataset contains 5,304 images with 10 object classes each, resulting in a sample size of 53,040 bounding box searches.

Entries in the object feature matrices are referred to as Sped Up Robust Feature (SURF) descriptors extracted from the original image using the same Support Vector Machine (SVM) formulation as in [19]. Figure 3 illustrates how a sparse matrix encodes an image and how SSS samples said sparse matrix. Entries in the sparse object feature matrix

Figure 3. A sparse object feature matrix with points sampled by SSS in green, and all non-sampled points in red.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-b4c69164-c41f-43ee-96ad-950018c7ac91.jpg)

are attributed different positive or negative weights. Figure 4 illustrates the highest weighted points in different images. These are points where the detector indicated increased likelihood of the object's presence.

To explore larger inputs, we increase the size of input sparse matrices using entry duplication. Each entry of the original matrix is transformed into a K × K submatrix with all entries equal to the original entry value. In this way, we arrive at a matrix that is K 2 times larger than the original matrix. In our experiments, we use K ∈ { 1 2 3 , , } .

## 4.2.2 RGB Color Channels

The RGB color channel data contains three types of data: 512x512 digital art, 1024x1024 digital art, and 2048x2048 high-resolution images, all obtained from the top 200 results of querying Google Images for 'digital art' and 'image', respectively, with the appropriate size constraints applied. Performance on randomized data of these sizes is also presented. For all of these datasets, the matrix entries are normalized such that the average entry is zero.

## 4.3. Metrics

We define the quality of an output submatrix, hereafter referred to as its accuracy, as a binary correct/incorrect evaluation on whether the output has an intersection over union (IoU) with the global optimum given some threshold, such as 50%. On the PASCAL dataset, A-ESS' accuracy with respect to the global optimum is 96.3% on all scaled versions of the data, meaning, for example, a 95% accuracy of SSS with respect to A-ESS corresponds to 91.5% global accuracy. On full (non-sparse) matrices, A-ESS' accuracy is between 98% and 100% and is thus a generally reliable reference point. We mostly use this reference point instead of computing the global optimum of all matrices in the given

Figure 4. Contents of sparse object feature matrices with only highly-positive points drawn.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-cfe1b491-4ca9-47fd-9ac8-716268836511.jpg)

datasets, which would be very computationally expensive. We will henceforth use the term 'accuracy' to mean IoU with respect to A-ESS's bounding boxes unless otherwise stated.

## 4.3.1 Spatial Coherence Score

Wedefine a spatial coherence score - how similar neighboring entries of a given matrix are - to gain insight into SSS' accuracy across a variety of data. This score is obtained by calculating the average differences between matrix entries and their spatially neighboring entries. This results in a low score when a given matrix is noisy or random and a high score when a given matrix has many entries whose nearby entries are similar, such as one that contains a large blue sky. This type of spatial coherence also manifests in other patterns, such as objects (many 'dog-like' features are surrounded by similarly dog-like features).

Formally, we define the spatial coherence C of a matrix M as:

$$C = 1 - D \quad \quad \ \ ( 3 ) \quad \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$$

where D is the spatial dissimilarity in M , defined as

$$D = \frac { \sum _ { x = 0 } ^ { n } \sum _ { y = 0 } ^ { n } \sum _ { d _ { x } = - r } ^ { r } \sum _ { d _ { y } = - r } ^ { r } | M [ x, y ] - M [ x + d _ { x }, y + d _ { y } ] | } { c \times | M _ { m a x } - M _ { m i n } | } \quad \begin{array} { c } \cdot & \cdot \\ \cdot & \cdot \\ \cdot & \cdot \\ \end{array} \\ \text{where $r$ is the square radius where in a given entry of $M$ is} \quad \text{run} \end{array}$$

where r is the square radius wherein a given entry of M is compared to its neighbors, M max and M min are the maximum and minimum value entries in M , and c is the total number of comparisons made. The denominator regularizes the entry differences aggregated in the numerator against the number of comparisons made, yielding a value D ∈ [0 , 1] ⊂ R . C = 1 -D then describes the inverse of the amount of spatial dissimilarity: the spatial coherence of the matrix. C is thus a standardized metric for measuring and

Table 2. Average running times of Bentley's algorithm, A-ESS, and SSS on PASCAL data. Times listed for SSS are those where the algorithm obtains at least 95% accuracy with respect to A-ESS.

| Scaling K × K   | Bentley [ms]   |   A-ESS [ms] |   SSS [ms] |
|-----------------|----------------|--------------|------------|
| (no scaling) 1  | 309            |        0.498 |      0.264 |
| 4               | 3,533          |        1.319 |      0.306 |
| 9               | 14,381         |        2.896 |      0.5   |

comparing the spatial coherences of matrices independent of their size, sparsity, and the magnitude of their entries.

## 4.4. Independent Variables

In our experiments, we examine the effects on SSS' performance of five independent variables: (1) size of input O n ( 2 ) , (2) data source, (3) IoU threshold, (4) randomization (on/off), and (5) SSS' stride lengths as functions f ( n ) of the input size O n ( 2 ) in the following set:

$$\{ \log \log n, \log n, \sqrt { n }, \log ^ { 2 } n \} \quad \quad ( 5 )$$

We use a constant iteration cap I cap of 20 for SSS when handling full matrices (no PASCAL trials triggered loop cases). We calculate the spatial coherence C of a matrix using a square radius r = 5 which we find to be sufficiently informative for the purposes of our analysis.

## 4.5. Experiments

Table 2 presents the real-time running times of Bentley's algorithm, A-ESS, and SSS on various scalings of PASCAL data. Figure 6 displays performances of SSS on the PASCAL dataset using stride lengths as functions f ( n ) . Figure 7 illustrates SSS' performance on RGB color channels of digital art and high-resolution images, alongside correspondingly-sized random matrices. On this diverse set of data, C is used to gain insight into its effects on SSS' accuracy performance. Figure 5 details SSS' performance across varying IoUs.

## 4.6. Discussion

Figure 6 shows a relative comparison between SSS and A-ESS with SSS using varying stride lengths f ( n ) on various scalings of PASCAL data. As expected, accuracy and running time decrease as stride lengths increase, offering flexibility by choice of f ( n ) . The relative performance of SSS improves as the input size grows, demonstrating that SSS generally scales more gracefully than A-ESS. In particular, SSS achieves 95% the accuracy of A-ESS 2x faster at 50% IoU, the same accuracy 4x faster at 4x scaling, and, at 9x scaling, accuracies up to 99.9% at 90% IoU 2.2x faster. We found that SSS performs equally well across all 10 object classes in the PASCAL dataset.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-c6a206cc-5896-4c2b-bb5d-de199967d532.jpg)

Figure 5. SSS' accuracy on various data for various IoU percentages with f ( n ) = log n .

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-886cc6e3-8ad1-45a8-bc27-77501db6ae04.jpg)

Figure 6. Performance of SSS with respect to that of A-ESS on the PASCAL VOC 2006 dataset. Curve data between diamond points is obtained using constant values, such as f ( n ) = 5 . Some diamond points deviate from the curves due to slight variance in image dimensions, an artifact of the generalization to O n ( 2 ) matrices as opposed to O n ( × m ) .

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00140v2-figure-dfd1765d-67a8-4496-a85e-b5f95102551a.jpg)

In Figure 7, we observe that SSS easily achieves nearperfect accuracy 3.3x faster on all but small, random matrices. On high-resolution image data, it achieves a 45x speedup at 93% accuracy, an 11x speedup at 99% accuracy, and 99.5% accuracy at a 3.5x speedup. Figure 5 demonstrates that SSS performs increasingly well on more strict IoUs as spatial coherence and matrix size increase. We see that spatial coherence heavily influences SSS' performance: all of the worst performances have significantly lower coherence scores. Thus, spatial coherence affects SSS' accuracy more than n does, making it the single best predictor of accuracy for all datasets used in this work.

We found that poor accuracy performance on small, random matrices is largely due to reaching the iteration cap which prevents infinite loop cases triggered during SSS'

Figure 7. SSS' performance with respect to that of A-ESS on 512x512 and 1024x1024 digital art, 2048x2048 high-resolution images, and correspondingly-sized randomized matrices for f ( n ) = { log log n, log n, √ n, log 2 n } (from left to right). C denotes a dataset's coherence score. A-ESS achieves 98%-100% accuracy on all datasets.

search phase. We found that the chance of this case occurring decreases precipitously as matrices increase in size or coherence. We observed this probability to be 20%, 11%, and 4% for n = 512 1024 2048 , , random matrices, respectively, and 0.7% uniformly across all sets of non-random matrices. If these cases are omitted, SSS' 50% IoU accuracy on 512x512 random matrices, for example, increases from 78% to 91%. SSS' increase in accuracy on increas-

ingly large random matrices in particular can thus be largely attributed to the prevalence of these cases in small, random matrices.

Overall, we observe in SSS an expected trade-off between speed and accuracy. As the size of the inputs increases, SSS scales favorably with an increasing accuracytime ratio. On full spatially coherent matrices in particular, SSS achieves significant speedups at extremely competitive accuracy.

## 5. Conclusion

We have proposed SSS, a solution to the max-weight rectangle problem that, on many matrices, runs significantly faster than the state-of-the-art with limited to virtually no accuracy loss. The state-of-the-art, A-ESS, runs in linear time and space ( O n ( 2 ) ), whereas SSS runs in sublinear time and space: O ( n 2 f ( n ) ) . We have shown that SSS provides flexibility in a speed-accuracy trade-off setting, and at an increasingly favorable rate as the size and/or spatial coherence of the input increases. It is thus well-suited for realtime applications and against many matrices in general.

## References

- [1] Senjian An, Patrick Peursum, Wanquan Liu, and Svetha Venkatesh. Efficient algorithms for subwindow search in object detection and localization. In Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on , pages 264-271. IEEE, 2009.
- [2] Christoph H Lampert, Matthew B Blaschko, and Thomas Hofmann. Beyond sliding windows: Object localization by efficient subwindow search. In Computer Vision and Pattern Recognition, 2008. CVPR 2008. IEEE Conference on , pages 1-8. IEEE, 2008.
- [3] Jon Bentley. Programming pearls: algorithm design techniques. Communications of the ACM , 27(9):865-873, 1984.
- [4] Jonathan Eckstein, Peter L Hammer, Ying Liu, Mikhail Nediak, and Bruno Simeone. The maximum box problem and its application to data analysis. Computational Optimization and Applications , 23(3):285-298, 2002.
- [5] Takeshi Fukuda, Yasukiko Morimoto, Shinichi Morishita, and Takeshi Tokuyama. Data mining using two-dimensional optimized association rules: Scheme, algorithms, and visualization. ACM SIGMOD Record , 25(2):13-23, 1996.
- [6] Paul Fischer, Klaus-U H¨ offgen, Hanno Lefmann, and Tomasz Luczak. Approximations with axis-aligned rectangles. In International Symposium on Fundamentals of Computation Theory , pages 244-255. Springer, 1993.
- [7] Pierre Sermanet, David Eigen, Xiang Zhang, Micha¨ el Mathieu, Rob Fergus, and Yann LeCun. Overfeat: Integrated recognition, localization and detection using convolutional networks. arXiv preprint arXiv:1312.6229 , 2013.
- [8] Hongyang Li, Yu Liu, Wanli Ouyang, and Xiaogang Wang. Zoom out-and-in network with recursive training for object proposal. arXiv preprint arXiv:1702.05711 , 2017.
- [9] Arturs Backurs, Nishanth Dikkala, and Christos Tzamos. Tight hardness results for maximum weight rectangles. arXiv preprint arXiv:1602.05837 , 2016.
- [10] Jasper RR Uijlings, Koen EA Van De Sande, Theo Gevers, and Arnold WM Smeulders. Selective search for object recognition. International journal of computer vision , 104(2):154-171, 2013.
- [11] Ying Liu and Mikhail Nediak. Planar case of the maximum box and related problems. In CCCG , volume 3, pages 11-13, 2003.
- [12] Jonathan Backer and J Mark Keil. The mono-and bichromatic empty rectangle and square problems in all dimensions. In Latin American Symposium on Theoretical Informatics , pages 14-25. Springer, 2010.
- [13] Deepak Agarwal, Jeff M Phillips, and Suresh Venkatasubramanian. The hunting of the bump: on maximizing statistical discrepancy. In Proceedings of the seventeenth annual ACMSIAM symposium on Discrete algorithm , pages 1137-1146. Society for Industrial and Applied Mathematics, 2006.
- [14] Hisao Tamaki and Takeshi Tokuyama. Algorithms for the Maxium Subarray Problem Based on Matrix Multiplication. In SODA , volume 1998, pages 446-452, 1998.
- [15] Zhaofang Wen. Fast parallel algorithms for the maximum sum problem. Parallel Computing , 21(3):461-466, 1995.
- [16] C Lawrence Zitnick and Piotr Doll'ar. Edge boxes: Locating object proposals from edges. In European conference on computer vision , pages 391-405. Springer, 2014.
- [17] Ming-Ming Cheng, Ziming Zhang, Wen-Yan Lin, and Philip Torr. BING: Binarized normed gradients for objectness estimation at 300fps. In Proceedings of the IEEE conference on computer vision and pattern recognition , pages 3286-3293, 2014.
- [18] M. Everingham, A. Zisserman, C. K. I. Williams, and L.VanGool. The PASCAL Visual Object Classes Challenge 2006 (VOC2006) Results. http: //www.pascal-network.org/challenges/VOC/ voc2006/results.pdf .
- [19] MatthewB Blaschko and ChristophH Lampert. Learning to localize objects with structured output regression. In European conference on computer vision , pages 2-15. Springer, 2008.
Max Reuter Gheorghe-Teodor Bercea Liana Fong
"Sliced" Subwindow Search: a Sublinear-complexity Solution to the Maximum Rectangle Problem
Considering a 2D matrix of positive and negative numbers, how might one draw
a rectangle within it whose contents sum higher than all other rectangles'?
This fundamental problem, commonly known the maximum rectangle problem or
subwindow search, spans many computational domains. Yet, the problem has not
been solved without demanding computational resources at least linearly
proportional to the size of the matrix. In this work, we present a new approach
to the problem which achieves sublinear time and memory complexities by
interpolating between a small amount of equidistant sections of the matrix.
Applied to natural images, our solution outperforms the state-of-the-art by
achieving an 11x increase in speed and memory efficiency at 99% comparative
accuracy. In general, our solution outperforms existing solutions when matrices
are sufficiently large and a marginal decrease in accuracy is acceptable, such
as in many problems involving natural images. As such, it is well-suited for
real-time application and in a variety of computationally hard instances of the
maximum rectangle problem.