1 Introduction

In this work, we introduce a methodology for solving a set of image processing problems based only on simple logical operations. Such restriction allows its implementation on a variety of devices not only based on a central processing unit (CPU) computation, as well as in graphics processing unit (GPU), field-programmable gate array (FPGA) or even simple application-specific integrated circuits (ASIC).

Before presenting the proposed methodology, it is needed to define our computational model to perform complexity analysis that should be far in any chosen architecture to implement it. In our computational model, we considered the most basic operation as the access of a pixel from an image data source, that could be a sensor, a file, a service or any mean that provides that information as O(1).

A hypercube Q n is a graph with 2n vertices, where its vertices are binary n-vectors and two vertices are adjacent in the hypercube if the Hamming distance between them is equal to 1. We start embedding the image data source on a hypercube by mapping the image 2D coordinates to a Binary Gray Code axis. This way, all pixels that are neighbors in the image data source are neighbors on the hypercube as well (the opposite is not valid) and each node belonging to the hypercube represents a pixel in the image. Using this approach, one can benefit from the multidimensional properties of the hypercube as the projection in different vector spaces. Vector space projections usually involve calculations that require complex arithmetic units that are beyond the scope of the presented framework. However, one can perform such operations on the hypercube using only simple logic units.

In order to take advantages of the hypercube topology, it is necessary the employment of an efficient way to construct it entirely or partially. Therefore, we use the algorithm proposed by Silva et al. [42] to construct independent spanning trees [50] over the hypercube. As we are not working with spanning trees directly, we can disregard the memory consumptions since we process each edge (composed of a pair of pixels in image) once. Actually, Silva et al. [42] algorithm builds a directed hypercube and its edge generation has no repeated edge even without marking the visited edges in the hypercube case (in the case of the spanning trees, it requires a bit per vertex). Thus, the complexity for the construction of the proposed technique is constant in terms of memory, that is, O(1).

As the technique complexity regarding required memory requirements and computational resources remain low, it is still necessary a simple operation that performs projections onto other vector spaces. For this purpose, it is only used a transformation operation that maps each coordinate of the hypercube to a vector space D − 1 or D + 1. This operation is the one-bit shift right of each hypercube coordinate in the case of downsampling an image w × h to w/2 × h/2 and logical shift to the left to increase the resolution, where w and h are the width and height of the image, respectively. The increase in resolution requires some work regarding interpolation. The number used in the shift right logical operation generates 2n image samples and, although the images are similar, they are merely redistributions of the original image pixels.

With the proposed technique, it is possible to generate low resolution images samples with the complexity of the sample size, i.e. w × h sample pixels no matter the original resolution of the image is. Regarding other multiscale methods, only considering them as one access per pixel, the complexity is O(n). Thus, if we have an image of, for instance, 512 × 512 pixels and we need a 64 × 64 pixel sample image, then 262,144 pixel accesses will be required against 4,096 used in the proposed method. As it has no interpolation or change on the information of the pixels besides its repositioning on the image, some characteristics as histogram are quite preserved. Our results show that the proposed method preserves the geometric features of the image better than other multiscale methods.

The proposed method can be applied to a variety of problems. It can provide image search gains by using the low resolution samples of the image before going through the entire image at original resolution. It allows reduction on the processing time in real-time applications, such as vision-aided vehicle driving systems or robot path-planning systems, which require to process thousands of images per second.

As main contributions of this work, we provide a simple way to perform preliminary image analysis in real-time systems on very limited computing power devices, and provide new perspectives on how to traverse images based on the desired goal. We provide satisfactory results with simple operations which can contribute to an initial sorting of images before applying more expensive traditional methods from a computational point of view. Our operations are based upon simple logic units and simple pixel access using some coordinate transformation functions providing fast and effective results. To the best of our knowledge, there is no previous work that applies transformations to images by simply translating and rotating hypercube coordinates.

The remainder of the paper is organized as follows. Section 2 briefly describes some concepts related to hypercube graphs and their applications. Section 3 presents the methodology proposed in this work. Section 4 describes and discusses the experiments and results. Section 5 concludes the paper with final remarks and directions for future work.

2 Background

Before presenting the methodology, it is necessary to define some terms that are used throughout this work, as well as some conventions proposed here.

A graph G is an ordered pair of disjoint sets (V,E) such that E is a subset of V (2) of unordered pairs of V. Let G be a graph, then V = V(G) is the vertex set of G and E = E(G) is the set of edges. An edge x,y joins the vertices x and y and is denoted by xy. Then, xy and yx refer to the same edge. If x yE(G), then x and y are adjacent vertices of G, and the vertices x and y are incident to the edge xy. Two edges are said adjacent if they have exactly one common endvertex [4]. A path is a sequence of vertices v 0,v 1,v 2,...,v l describing the route of the vertex i towards the vertex j. A cycle in a graph is a subset of edges that represents a path such as that the first vertex of the path corresponds to the last vertex.

A graph G has a Hamiltonian path if, and only if, there is a path in G such that each vertex is visited once. A Hamiltonian cycle is a cycle that forms a Hamiltonian path.

The hypercube, also called n-cube and usually denoted as Q k , is a k-connected graph with a special property where each vertex and its adjacent differ in only one bit in their binary representations, as illustrated in Fig. 1.

Figure 1
figure 1

Two vertices are adjacent in the hypercube if their symbols differ exactly in a single coordinate.

An m-bit Gray code, G m , denotes a sequence of all binary numbers of m-bits. G 1 is defined as (0, 1) and for m > 1, G m is defined recursively in terms of G m−1 as (0G m−1,1G m−1 r), where G m−1 r is the reverse order G m−1 and 0G m−1 (1G m−1 r) is the advance fixing of each binary number G m−1 (G m−1 r) as 0 (1) [21].

For instance, a binary number sequence (000, 001, 011, 010, 110, 111, 101, 100) is a Gray code of 3 bits representing a path in a hypercube of 23 vertices (3-cube), starting with vertex 000 and finishing at vertex 100.

The Hamiltonian property of the hypercube is strongly related to the theory of Gray codes [22, 43, 48]. Hypercubes are often used in networks [3, 28, 46] due to their valuable properties in fault tolerant systems, their symmetry and logarithmic distance between the vertices available in commercial implementations such as iPSC [23] and nCUBE [35]. Several algorithms have been proposed to embed important topologies on the hypercube such as rectangular meshes [6, 25], trees [13, 20] and pyramids [29, 51]. For additional information about hypercube properties, the reader may consult [18].

Hypercubes are not a novel topic in the computer field. Cover [9] used them to give the upperbounds on the number of polynomially separable Boolean functions. Pease [36] employed the hypercube topology to explore the possibility of its use as a large scale array of microprocessors as computational facility due to the high degree of parallelism.

Some hypercube algorithms have been employed to address problems in coding theory [26], linguistics [16], computer system design [19], image analysis [7, 10, 31, 33, 38, 52], pattern recognition [24, 34, 37, 40] and computational geometry [8, 30, 32, 41]. For additional information about properties and applications of hypercube graphs, the reader can refer to [2, 12, 18, 39].

Graph representation has also been utilized in several image processing problems. Eshera and Fu [15] described a semantic-synthatic model based on attributed relational graphs to understand the content of images. Wu and Leahy [49] presented a graph theoretic approach to data clustering, such that the problem is formulated as the optimal partitioning of an undirected graph into a number of subgraphs. The clustering algorithm is applied to segment images.

Trémeau and Colantoni [44] developed structures and algorithms based on region adjacency graphs to segment color images, improving other segmentation approaches such as region growing or watershed transformation. Uyttendaele et al. [45] presented methods for automatically creating image mosaics from a set of panoramic photographs through a graph of regions of difference between input images.

Methods based on graph cuts construct a specialized graph for the energy function to be minimized [27]. These methods have been applied to a variety of image processing problems, such as image restoration [11], image segmentation [47] and medical imaging [5]. Elmoataz et al. [14] presented a non-local discrete regularization approach on weighted graphs for image and manifold processing.

The majority of the research work on image processing using hypercubes developed in the 1980 and 1990 decades reports the application of algorithms with n-cube or hypercube architecture present in supercomputers such as iPSC [23] and nCUBE [35]. In contrast, the hypercube dimensions used in our method are based on the image size, O(log(wh)), such that for an image of 4096 × 4096 pixels, for instance, the hypercube has 22 dimensions. Our algorithm for constructing the hypercubes does not need any memory in the construction stage and the edges are used on demand and discarded right after their use.

3 Methodology

This section describes the methodology developed for the image manipulation by simply mapping the original image coordinates to the hypercube topology. Two operations are analyzed: edge detection and multiscale decomposition.

The edge detection is performed locally using only two vertices at a time that represent two neighbor pixels in the original image through a very simple approach in which a border exists if an active pixel and an inactive one are neighbors in the original image.

Differently, the multiscale decomposition translates each pixel of the image to a new coordinate, such that the decomposition can be performed by just accessing the pixels of the original image without any other computation involving the generation of new values. Furthermore, all the pixels present in a multiscale decomposition are present in the original image with values of identical band intensities. Such approach provides a more accurate analysis of the original image through the processing of its multiscale decomposition samples. For instance, one can perform a search for a specific color in an image via its decomposed samples, which reduces the required processing time.

The following describes the steps needed by the methodology proposed in this work. Initially, an image is mapped to the hypercube topology, such that the mapping is performed as follows: each hypercube coordinate is obtained by concatenating the bits representing the X-Y image coordinates using their equivalent Gray code, resulting in a binary representation of the hypercube vertex. Figure 2 shows the mapping of an image with 8 × 4 pixels to the hypercube Q 5. After that, one can handle the image operations based on the hypercube topology, almost disregarding the image grid representation.

Figure 2
figure 2

Mapping an image of 8 × 4 pixels to the hypercube Q 5.

Figures 3 and 4 show schematic diagrams representing the proposed methodology. Our approach provides a proper level of abstraction since it simplifies the traditional way to deal with usual image processing problems. For instance, the edge detection is handled by using only a hypercube edge, i.e., a threshold is established and an edge is present if one of the vertices is below and the other is above the threshold established.

Figure 3
figure 3

Diagram with the main stages of the proposed methodology.

Figure 4
figure 4

Diagram with the main stages of edge detection methodology.

Algorithm 1 is used to navigate in the image as a hypercube. Initially, the vertex set is traversed (Line 2), the neighboring dimensions are explored (Line 3), edge repetitions are avoided (Line 4) and, finally, the edges are generated (Line 5).

figure c

We provide some factors of multiscale decomposition by the simple translation of the original coordinate space to another one. For instance, to generate an image with half of the original scale, we transform the hypercube by shifting all vertices by 1 bit to the right-hand side, causing the translation of the pixels to a new vectorial space, as illustrated in Fig. 5.

Figure 5
figure 5

Translation of the coordinates through 1-bit logic shift right operation.

The number m used in the shift transformation operation results in 2m multiscale decompositions of the image. Figure 6 illustrates a decomposition resulting in two sample images, each one with the half of the original resolution.

Figure 6
figure 6

Original image and the result of the translation of the coordinates using 1-bit logic shift right operation.

4 Experimental Results

This section presents the experimental results obtained by applying the proposed methodology to a number of images. The experiments were performed on an AMD FX-6300 3.5 GHz processor and 8 GB of memory. The algorithms were implemented in Java programming language.

Figure 7 shows the results for different logical operations on an input image. It is possible to observe the multiple resolutions and horizontal/vertical flips obtained only by coordinate translations with simple operations.

Figure 7
figure 7

Results for multi-resolution and horizontal/vertical flips on an image.

Results for edge detection are shown in Fig. 8. A comparison among the method based on hypercube graphs and two traditional image edge detection methods (Sobel and Canny) [17], is performed. A threshold value of 80 was used in the Sobel method. A standard deviation of 0.45 and an upper and lower threshold of 50 and 110, respectively, were used in the Canny edge detector. Our method used a threshold value of 90. The proposed method was able to capture fine details present in the image.

Figure 8
figure 8

Results for different edge detection methods.

Figure 9 shows the results for different resampling methods, including the nearest neighbor, bilinear and bicubic interpolation techniques. The proposed method is referred here to as raw hypercube due to the fact that we purely apply the transposition of pixels without any interpolation or any other modification. This means that the signal information of the original pixel is retained as one can see by the lack of smoothing on the resulting image. Furthermore, the final image quality obtained by such a simple method is relevant.

Figure 9
figure 9

Results for different image resampling methods.

Figure 10 shows the results for different resampling methods with a specific target. The square border in the original image is one pixel thick. Our method preserves the original pixel color information that facilitates search for a particular color belonging to the target object.

Figure 10
figure 10

Results for different image resampling methods.

Other results for resampling methods are shown in Fig. 11. It is possible to observe that our method preserved the geometric characteristics of the original image, whereas none of the other tested techniques maintained the one-pixel separation between the parallel lines present in the original image. This may be advantageous in the search for images by texture since the information in the original image texture patterns are preserved in the subsamples.

Figure 11
figure 11

Results for different image resampling methods.

Figure 12 shows the results for a multi-resolution search using the hypercube. In this experiment, the purpose is to search for a specific blue car at the bottom center of the image. The search starts at a resolution from 1 × 1 to w × h, where w and h are the width and height of the image, respectively. The car was found in the 3,035-th pixel of the image with resolution of 64 × 64 pixels. Therefore, the total cost was 20 + 21 + 22 + 23 + 24 + 25 + 3,035 = 3,098 accesses. On the other hand, a sequential search on the entire image found the pixel with cost of 422,660 accesses.

Figure 12
figure 12

Example of multi-resolution search using the hypercube for different image resolutions.

The number of operations required for a pixel interpolation is a commonly used strategy for assessing complexity cost [1]. The metric includes the operations demanded both for the convolution and for the calculation of the basis function. The convolution operation of an m × m mask requires m 2 multiplications and m 2 − 1 additions. Table 1 reports the number of operations per pixel for the nearest neighbor, bilinear and bicubic interpolation methods, as well as for the proposed hypercubic approach. Our method has cost 0 for both operations since it uses the original pixel values.

Table 1 Number of operations per pixel required for different interpolation methods.

5 Conclusions and Future Work

In this work, we presented and evaluated an approach to solving a number of image analysis problems using the hypercube graph. We were able to satisfactorily deal with different problems in a simple and flexible way.

We performed transformations on the images with only the granularity of the hypercube vertices and edges. The strategy for generating the edge set is easily parallelized and the transformations hereby described are restricted to simple logic operations that simplified the final hardware design.

As directions for future work, we intend to propose different logical operations and apply the method to other image analysis problems.