For 2d images for performing median filtering we have inbuilt function medfilt2
is there any function for performing median filtering rgb images
The help is a good place to look for this information. If you type in median there, you'll see that you can use medfilt2() in the Image Processing Toolbox. I have a demo that uses medfilt2() to remove salt and pepper noise in RGB images, if you want to see it.