I love this kind of question: they are easy enough for me to solve, and it makes me research the reference, as I am still new to Processing.
I found that filter() is either a function acting on the whole display, or a method of PImage, acting on such image.
So the solution I found is as follow:
Code:// Unlike what the reference says, absolute paths work. Except in applets. And it is not portable, of course!
PImage niceImage = loadImage("D:\\_PhiLhoDocs\\DA\\SurfStyle.jpg");
// Dimension to image size
size(niceImage.width, niceImage.height);
// Display whole image
image(niceImage, 0, 0);
// Create a sub-image
// Starting at 20% of top-left sides
int posX = int(niceImage.width * 0.2);
int posY = int(niceImage.height * 0.2);
// And at 20% of bottom-right sides (100%-20%-20% = 60%)
int subWidth = int(niceImage.width * 0.6);
int subHeight = int(niceImage.height * 0.6);
// Create a sub-image of the needed size
PImage subImage = createImage(subWidth, subHeight, RGB);
// Copy a part of the main image into the sub-image
subImage.copy(niceImage, posX, posY, subWidth, subHeight, 0, 0, subWidth, subHeight);
// Apply the filter
subImage.filter(INVERT);
// And display the sub-image over the main one (the display)
image(subImage, posX, posY, subWidth, subHeight);
Perhaps there is more elegant way to do this which I overlooked.
Otherwise, this code snippet should be wrapped in a function for easier reuse.