I'm trying to run a customized filter through an image, using the colfilt function. This filter basically runs a window nxn through the image, and replaces the central pixel by the half of its minimum and maximum sum. This is what the code looks like:
colfilt(image, 3, "sliding", @(x) (min(x(:))+max(x(:)))/2)
However, I'm getting this error:
error: col2im: can't resize B in matrix sized (A_SIZE - BLOCK_SIZE +1)
error: called from:
error: /usr/share/octave/packages/image-2.2.1/col2im.m at line 143, column 9
error: /usr/share/octave/packages/image-2.2.1/colfilt.m at line 152, column 9
If I replace the function by the nfilter, like below
nlfilter(image, [n n], @(x) (min(x(:))+max(x(:)))/2)
It works fine, but it's too slow, so I think the first option must work better.
Does anyone know how to make it work?
Thanks in advance.