sliding window operation in image

I have an image of size 256*256, i want to use 3*3 window which slides over image and change the value of central pixel as sum of neighbouring 8 pixels. Please Help.

 Risposta accettata

Image Analyst
Image Analyst il 26 Giu 2014

0 voti

Try conv2(), imfilter(), nlfilter(), or, if you want to move in "jumps" instead of by one pixel, blockproc().

3 Commenti

VIJENDRA
VIJENDRA il 26 Giu 2014
Modificato: Image Analyst il 26 Giu 2014
thanks for your reply and i see the function usage of above said function but if my function is:
function y=shannon_entro(x)
[M,N]=size(x);
y=zeros(1,N);
for l=1:N
y(l) = -( sum(x(:,l).*log(x(:,l))) );
end
then how can i implement it in 3*3 manner in image using above functions.
one can use nlfilter or blockprop.
Sorry, for some reason I didn't see your follow up question from June until now. Please see my demo of nlfilter where you can have it perform your own custom operation/filter on the window at each location.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by