The median filter takes in the neighbourhood the median color (see Median filter)

(to test the function below, you can use these input and output solutions)

 
FUNCTION MEDIANF,ARRAY,WINDOW
	RET=fltarr(N_ELEMENTS(ARRAY),1)
	EDGEX=WINDOW/2
	FOR X=EDGEX, N_ELEMENTS(ARRAY)-EDGEX DO BEGIN
		PRINT, "X", X
		COLARRAY=fltarr(WINDOW,1)
		FOR FX=0, WINDOW-1 DO BEGIN
			COLARRAY[FX]=ARRAY[X + FX - EDGEX]
		END 
		T=COLARRAY[SORT(COLARRAY)]
		RET[X]=T[WINDOW/2]
	END
	RETURN, RET
END
 