0
$\begingroup$

I struggle to find this, suppose I apply any feature detection algorithm. From my references it seems to me it's not usually explained what kind of data structures would be suitable for storing such features.

For example in opencv it seems to me that the Canny Edge detector will return a matrix (I assume the code/gray level code is like relating high pixel value with the the feature in that specific pixel). I think it would be useful to know what data structures could actually be useful in this case to navigate through all the extracted features instead of iterating through all the pixels.

So the question is... in general (or at least line features) what data structure is usually useful? and how is such data structure constructed?

As a specific example... I'd like to extract all the edges of a given image, name such edges $e_1,\ldots,e_n$. Then I need to access to the pixels that lie both to the left and right of such edge(not all, just pixels that are close enough to $e_i$, for all $i$). Finally I need to perform some operations on such pixels.

To summarize something like:

$e_1,\ldots,e_n \leftarrow extractEdges(I)$

$\forall i \in \left\{ 1,\ldots, n\right\}$

$\;\; S_l \leftarrow pixelsLeft(e_i)$

$\;\; S_r \leftarrow pixelsRight(e_i)$

$\; \; doSomething(S_l,S_r)$

Above $I$ representes the input image.

Thank you

$\endgroup$
1
$\begingroup$

A simple solution would be a 2D array containing a 1 in the locations that are detected as an edge, or a sparse 2D matrix. A more sophisticated solution would be a quadtree.

$\endgroup$
  • $\begingroup$ Any references for such approach? I mean the quad tree $\endgroup$ – user8469759 Jul 23 '18 at 21:15
  • $\begingroup$ @user8469759, if you google it you will probably find a Wikipedia article. I encourage you to be resourceful and I'm sure you will be able to find many resources on the subject. Please don't use comments for follow-up questions; you can ask a new question using the 'Ask Question' button, after doing some research. $\endgroup$ – D.W. Jul 23 '18 at 22:48
  • $\begingroup$ There's still a bit I don't understand, say you use a sparse matrix to store pixels corresponding to edges. How would you take into account whether or not given two pixels these belong to the same edge? One could look for adjacent pixels, but it might be possible that these two would belong to two adjacents edges. $\endgroup$ – user8469759 Jul 24 '18 at 8:45
  • $\begingroup$ @user8469759, I don't know; that wasn't part of the question. The Canny edge detector doesn't tell you whether or not two pixels belong to the same edge; you have to do some preprocessing for that. Presumably, you'll have to do the same preprocessing if you want to use one of these data structures, and then encode which edge it is part of (e.g., assign a unique ID to each edge, and store that ID in the corresponding location of the matrix instead of a 1). $\endgroup$ – D.W. Jul 24 '18 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.