![]() |
Finding the upper-right "crotches" of a matrix
<p>First, apologies for my description. I don't know the matrix semantics related to this type of operation so I cannot even begin to know how to search for it.</p>
<p>In matlab, I have a matrix A:</p> <pre><code> 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 0 1 </code></pre> <p>That I would like to transform to become something like B:</p> <pre><code> 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 </code></pre> <p>Where the 1's correspond to row-col locations with 1's in the 5 positions above and to the right AND [there is a single 1 either to the left or below OR both left and below positions are zero].</p> <p>I can see how this might doable by iterating through each position in A, but this may be slow for very large matrices. I was wondering if there is a filter2 or xcorr2 based approach in matlab that might be faster? I tried both with various kernel matrices on a padded version of A (1-padded above and to the right, 0-padded left and below) but can't come to a definitive answer.</p> [url=https://stackoverflow.com/questions/59037569/finding-the-upper-right-crotches-of-a-matrix]More answer...[/url] |
所有时间均为北京时间。现在的时间是 19:41。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.