# load image and convert to grayscale img = Image.open(img_name).convert('L') # convert to 3 group color img3groups = img.quantize(colors=3, kmeans=100) # filter erosion & dilation (6 times) img_filtered = img3groups.convert("RGB") for i in range(6): img_filtered = img_filtered.filter(ImageFilter.MaxFilter()) for i in range(6): img_filtered = img_filtered.filter(ImageFilter.MinFilter()) *NBHF.PEVMFc1JMMPX PythonͰ֤ߏཁૉͷಛΛੳ͢ΔᶃɿҰ෦ղઆ