MATLAB: How to apply median filter to a color image

Image Processing Toolboxmedian filter

I applied median filter to a color image.. herewith i have mentioned the code.. is it correct?
img=shadow_imadjust;
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
medfilimg(:,:,1) = medfilt2®;
medfilimg(:,:,2) = medfilt2(G);
medfilimg(:,:,3) = medfilt2(B);
figure,imshow(medfilimg);

Best Answer

Change this
medfilimg(:,:,1) = medfilt2®;
to
medfilimg(:,:,1) = medfilt2(R);