I think several points should be checked:
- File path in the line 1 is correct?
- 3rd input argument of imnoise function should be separated by ','
- imfilter function should be used in th eline 4, instead of filter2 function
- uint8 in the last line can be deleted
The following is an example.
I = imread('exp.jpg');
isp = imnoise(I,'salt & pepper',0.1);
a = fspecial('average');
a1 = imfilter(isp,a);
figure;imshow(a1);