Learn Before
Code
ImageMath Class Example (Python)
The following code uses the eval() function to take the maximum value of two images and then convert the result into the "L" (8-bit black and white) color mode.
# Importing Image module from PIL package from PIL import Image, ImageMath # creating a image object im1 = Image.open(r"C:\Users\System-Pc\Desktop\ybear.jpg").convert('L') im2 = Image.open(r"C:\Users\System-Pc\Desktop\leave.jpg").convert('L') # applying the eval method out = ImageMath.eval("convert(max(a, b), 'L')", a = im1, b = im2) out.save("result.jpg") out.show()
0
1
Updated 2021-08-29
Tags
Python Programming Language
Data Science