performance - Matlab execute function each cell Matrix with matrix and cell postion as arguments -
performance - Matlab execute function each cell Matrix with matrix and cell postion as arguments -
i need apply function each pixel of each image in set of ~400 images. function wrote (called customf
) requires 3 arguments: matrix, , position of cell in matrix (m
, n
). position of pixel needed in order compute lbp (local binary pattern) requires values of surrounding pixels. customf(matrix, m, n)
returns integer d
0 < d < 256
, , store each value of d
in matrix of same size image.
given set quite large, i'd code efficient possible, don't understand how utilize cellfun
or arrayfun
in such way.
or improve solution? (using nested for
might inefficient?)
thanks!
can write customf
in different way? instead of working on entire image each pixel (m
, n
), why don't give local patch required computing lbp of patch's central pixel?
for example, if customf
needs @ pixels -/+ k
away m
, n
compute response d
@ m
, n
, may have
k = 5; localf = @( patch ) customf( patch, k+1, k+1 ); % assuming patch of size (2k+1)x(2k+1) % apply lbp image d = nlfilter( image, [2*k+1 2*k+1], localf );
note nlfilter
zero-pads image
in order obtain d
same size image
.
performance matlab matrix
Comments
Post a Comment