I did some mistake in my code.my goal is i wanna set 21x21 processing window over 255x255 image ,then i need to find median value by sorting the pixels for each window,then i wanna find difference between each pair of adjacent pixels of sorted pixel

1 view (last 30 days)
pls find what i wanna change in this code
for n=1:21
for m=1:21
b=noisy_img([n:n+20],[m:m+20]);
b
c=b(:);
d=sort(c);
k=numel(d);
e=median(d);
e
for i=1:k-1
f=d(i+1)-d(i);
f
end
end
end

Accepted Answer

Image Analyst
Image Analyst on 29 Oct 2014
Edited: Image Analyst on 29 Oct 2014
Why not just use medfilt2()? And what is this algorithm supposed to produce? Your third for loop does nothing but overwrite f 441 times because f is not indexed. In a 21 by 21 window there are 441 pixels, so you'll have 440 differences between pairs. What is the use of f if you could get it working and have all 440 elements of f. What does f represent?

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!