public static PackedImage sobelGradient(PackedImage img) {
		PackedImage gxImg = new PackedImage(img.rows(), img.cols());
		PackedImage gyImg = new PackedImage(img.rows(), img.cols());
		PackedImage outImg = new PackedImage(img.rows(), img.cols());
		Kernel gx = new Kernel("sobelGradientGx");
		Kernel gy = new Kernel("sobelGradientGy");
		gxImg = convolve(img, gx);
		gyImg = convolve(img, gy);
		
		for (int r = 0; r < img.rows(); r++) {
		    for (int c = 0; c < img.cols(); c++) {
		    	outImg.set(r, c, 0, (int) Math.round(Math.sqrt(gxImg.at(r, c, 0)*gxImg.at(r, c, 0) + gyImg.at(r, c, 0)*gyImg.at(r, c, 0)) / (Math.sqrt(2))));
		    	outImg.set(r, c, 1, (int) Math.round(Math.sqrt(gxImg.at(r, c, 1)*gxImg.at(r, c, 1) + gyImg.at(r, c, 1)*gyImg.at(r, c, 1)) / (Math.sqrt(2))));
		    	outImg.set(r, c, 2, (int) Math.round(Math.sqrt(gxImg.at(r, c, 2)*gxImg.at(r, c, 2) + gyImg.at(r, c, 1)*gyImg.at(r, c, 2)) / (Math.sqrt(2))));
		    }
		}
		
		return outImg;
	}