MATLAB: Why output image is showing blank

Image Processing Toolboximshow(round(k))

x=imread('cameraman.tif');
subplot(2,1,1);
imshow(x);
[m,n]=size(x);
y=zeros(m+2,n+2);
for i=1:m
for j=1:n
y(i+1,j+1)=x(i,j);
end
end
w=[1 1 1;1 1 1;1 1 1]./9;
k=zeros(m,n);
for d=1:m
for e=1:n
p=1;
q=1;
for i=d:d+2
q=1;
for j=e:e+2
z(i,j)=y(i,j);
z(i,j)=z(i,j)*w(p,q);
q=q+1;
end
end
a=mean(mean(z));
k(d,e)=a;
end
end
subplot(2,1,2);
imshow(round(k));

Best Answer

Because round(k) is a floating point array, it expects the values to be between 0 and 1 inclusive. To get around this use [] in imshow:
imshow(round(k), []);
or cast to uint8:
imshow(uint8(round(k)));