filter() is used in Processing to transform the currently displayed image. It takes one or two arguments.
The first argument can be a shader or a constant that indicates the kind of filter you want to apply. The available filters are THRESHOLD, GRAY, OPAQUE, INVERT, POSTERIZE, BLUR, ERODE, and DILATE. Shaders are very fast and powerful, but involve learning a new programming language, so we will leave that for later.
The second argument is optional and it is used to adjust some kind of setting on the filter. For example filter(BLUR, 6) means use the "blur" filter, and the blur should be 6 pixels wide.
Filters can be applied in series: first one, then another. They can also be applied multiple times, for example once each time draw() is called. Applying THRESHOLD, GRAY or POSTERIZE multiple times on the same exact image does not make much sense, as a gray image can not be "grayer". But if something does change in the image then it may make sense to apply again and again.
The amount of available filters is limited, but combining them in creative ways one can obtain interesting images.
Check out episodes 89 and 90 if you want to build your own custom filters.