Attempted to access pad_org(1,343); index out of bounds because size(pad_org)=[544,342].
Show older comments
original_im=imread('Picture1.tif');
figure,imshow(original_im);
pad_org=padarray(original_im,[1 1],'both');
figure(3);imshow(pad_org)
for i=1:size(pad_org,1)-2
for j=1:size(pad_org,2)-2
window=zeros(25,1); %%Matrix to store the value of 5 by 5 window
win_inc=1;%%initial value of window matrix
for k=1:size(window,1)/5
for l=1:size(window,1)/5
window(win_inc)=pad_org(i+k-1,j+l-1);
win_inc=win_inc+1;
end
end
median=sort(window); %%arranging the window by ascending order
new_image(i,j)=median(13);%%13 is the median value of 5 by 5 window
end
end
new_image=uint8(new_image);
figure(4);imshow(new_image);title('Image After Median Filtering')
I am getting an error as
Attempted to access pad_org(1,343); index out of bounds because size(pad_org)=[544,342].
Error in medianfilter_withoutbuiltin (line 54) window(win_inc)=pad_org(i+k-1,j+l-1);
I am unable sort out this error.
Please help me.
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!