added kernel size variable & medianIndex