I do have this code to increase the sharpness of the image using BufferedImageOp
class DecreaseSharpenFilter implements MyFilter{
public BufferedImage processImage(BufferedImage image) {
float[] decreaseSharpnessMatrix = {0.0f, +1.0f, 0.0f, +1.0f , -5.0f, +1.0f, 0.0f, +1.0f, 0.0f };
BufferedImageOp DecreaseSharpenFilter = new ConvolveOp(new Kernel(3, 3, decreaseSharpnessMatrix),
ConvolveOp.EDGE_NO_OP, null);
return DecreaseSharpenFilter.filter(image, null);
}
}
Now I want to convert image to black and white by doing modifications to these lines but I don't really know what values to use in the matrix and how to convolve it.
You just need to make a colorspace, then pass it in to your convertOP
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(cs, null);
BufferedImage image = op.filter(image, null);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.