public static double calculateCoverage(SimpleImage pImg, int bgRed, int bgGreen, int bgBlue, boolean useFilter) {
SimpleImage img;
if (useFilter) {
SimpleImage filteredImg = new SimpleImage(pImg.getBufferedImg(), pImg.getImageWidth(), pImg.getImageHeight());
ConvolveTransformer transformer = new ConvolveTransformer();
transformer.initDefaultParams(filteredImg);
transformer.setKernelType(KernelType.SOBEL_3X3);
transformer.transformImage(filteredImg);
img = filteredImg;
}
else {
img = pImg;
}