I have this function that calculates the value of the binary pattern of a 3*3 block which result form thresholding the 8 neighbers pixels with the center pixel and returns two outputs: the decimal value of the binary code, the same decimal value if it's uniform or 59 if not.
function [out1,out2] = lbpblock(im)
%... implementation details
out1 = decimal ;
out2 = uniform;
end
The problem is when trying to use blockproc like this
result = blockproc(im,[3 3],@lbpblock);
the result array is only two dimensions (eg. 85*85) and has only the first output.
when I tried
[res1 res2] = blockproc(im,[3 3],@lbpblock);
I get "Error using ==> blockproc Too many output arguments".
I tried to change the function signature
function out = lbpblock(im)
%... implementation details
out = [decimal, uniform];
end
the result array again two dimensions only but now (85*170) the first output is stored in odd columns and the second in even ones.
Is there any trick to get blockproc to store the result in a 85*85*2 array??
You can achieve an NxNx2 array as output by concatenating in the third dimension.
Example:
im = magic(10);
r = blockproc(im, [3, 3], @func);
function r = func(im)
r1 = mean(im.data(:));
r2 = std(im.data(:));
r = cat(3, r1, r2);
end
The important line is cat(3, output1, output2).
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