I am trying to prune a skeletonized image of numbers (0-9), which is sometimes highly branched because of irregularities in the original number thickness.
For this, I am trying to use the kernels shown in Fig. 4: http://homepages.inf.ed.ac.uk/rbf/HIPR2/thin.htm, which contain "don't care" cells.
Because I don't see how to code a "don't care" element in a kernel, I am creating other kernels to cover up all of the possibilities when taking into account the "don't care" elements. However, this greatly increases the complexity of the code, as it is computationally expensive. For example, take into account the first kernel in Fig 4:
kernel1 = [1 1 1; * 1 *; 0 0 0] -->
[1 1 1; 1 1 0; 0 0 0]
[1 1 1; 0 1 1; 0 0 0]
[1 1 1; 1 1 1; 0 0 0]
[1 1 1; 0 1 0; 0 0 0]
Where * denotes "don't care" elements. Directly coding a "don't care" element would be much less cumbersome, and it would largely decrease computation time.
Does anyone have any suggestions on how to deal with this?
Victor
Thank you for your answer!
With the help of your 'result' outcome, I was able to generate all possible matrices for any number of 'don't care' elements, n. This helped out a lot!
(If anyone's interested: )
n = numel(find(A == -1))
func = @(x,n) repmat( [ ones(1, 2.^(n-x)) zeros(1, 2.^(n-x)) ] , 1, 2.^(x-1))
ind = [1:n]' %'
result = cell2mat ( arrayfun(func,ind,n*ones(1,n)','UniformOutput',false) )'
[row,col] = find(A == -1)
for i = 1:size(result,1)
for b = 1:size(result,2)
output{i}(row(b),col(b)) = result(i,b);
end
output{i} = abs(new{i} + A + isnan(A));
end
Thanks again!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With