Problem to Threshold a Matrix
4 次查看(过去 30 天)
显示 更早的评论

I need to threshold the surrounding pixels of the given matrix with respect to the centre pixel of the given matrix. If the surrounding values are greater than or equal to the center of the pixel they are given a 1 otherwise they are given a 0. Then I need to store all the values in the shown order to result in a vector which contains the binary value.
2 个评论
James Tursa
2017-4-12
Have you tried coding this? What problems are you having? Not working, or too slow, or ???
采纳的回答
Image Analyst
2017-4-12
Let's call it what it is, okay? You're asking for the " local binary pattern".
For a FULL demo on the whole image, see the attached m-file. it creates this image

6 个评论
Image Analyst
2017-4-21
I don't understand why you want to do that. And anyway, you don't have one LBP feature for the entire image. Every pixel has its own local binary pattern, so you have millions of patterns.
更多回答(1 个)
James Tursa
2017-4-12
编辑:James Tursa
2017-4-12
Using your small example:
>> x = 2;
>> y = 2;
>> matrix = [ 85 99 21; 54 54 86; 57 12 13]
matrix =
85 99 21
54 54 86
57 12 13
>> t = matrix >= matrix(y,x)
t =
1 1 0
1 1 1
1 0 0
>> b = [t(y,x-1) t(y+1,x-1:x+1) t(y,x+1) t(y-1,x+1:-1:x-1)]
b =
1 1 0 0 1 0 1 1
>> d = sum(b.*2.^(7:-1:0))
d =
203
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!