Removing larger elements from an image