How to create binary kernels with 1's acting as lines going side to side and through the center?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to create many large binary kernels of 31x31 in which 2 lines of 1's go side to side and through the center.
example of 5x5

Above are all the solutions for a 5x5 but for a 31x31 there are many more and when all kernels are stacked it would look something like the figure below but with many more possible lines going through the middle.

I need to create one kernel for each possible angle a line can take in a 31x31 matrix and I was hoping somebody had an idea on how to do this.
Since the entire thing is very symmetric only an upper or lower triangle of one of the quarters of the figure needs to be created. The rest can than be easily constructed by mirroring a few times along the symmetry axes.
What I was thinking to do, but have absolutely no idea on how to code, is to have Matlab search for the shortest paths between the center pixel of a kernel and the border cells that are on the opposite side of the center in one of the 1/8 parts (triangle).

However, in a matrix, between a border cell and the center cell there are many paths of equal length so that is a bit of a problem when trying to find the line that is most appropriate. But it is my best idea so far and I can't even code it.
All help is welcome. Thanks in advance
0 commentaires
Réponse acceptée
Image Analyst
le 13 Juin 2014
I would just use imline to burn a line into an image (an array). Just have one end of the line start at the upper left and the other end at the lower right and call imline. Then move each endpoint one pixel clockwise until you've traversed the entire perimeter. See my demo to learn how to use imline to burn a line into an image.
If you can't figure out how to adapt it, after trying, then perhaps I can help if I have time.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!