Hello dear all I am trying to create a function that performs sliding block processing in an image. More specifically, it starts by selecting the first 210×210 block of the image (from top left corner), performs the function, and then increments the row and column coordinates 20 pixels right and down.
I have cheated the function for nlfileter, but it is not logic, it puts a white pixel after each 20 pixels, it is ok for the first row but what i want, it increments 20 pixels down after firs row finished but unfortunately i did not able to this. My codes are given in below please give me a logical ideas for by incrementing 20 pixels down to the end of image
———————— nlfileter_test.m file——————-
% Sliding neighborhood filtering example
close all; clear all; clc;
global num;
cnt = 1;
num = 0;
I = imread('o11.jpg');
I = rgb2gray(I);
fun = @fn_extr_img_features;
disp('Performing Sliding Neighborhood Operation')
tic
I2 = nlfilter(I,[210 210],fun);
toc
imshow(I), title('Original')
figure
imshow(I2, []), title('nlfilter')
——————————————————————————–
——————-fn_extr_img_features.m file——————
function y = fn_extr_img_features(x)
global num;
if (mod(num, 20) == 0) % this codes makes one white pixel atfer each 20 pixels black pixel.
y=255;
else
y = 0;
end
num = num + 1;
end
…………………………………………………………………..
Best Answer