prateek:
どのように画像の画素がぼやけたものに比べて焦点にあるかを検出します。カメラの多くは持っている「フォーカスピーキング」機能のようなもの?
アイデアは、画像をクリックしながら、それは、ユーザを支援するようにフォーカスしているピクセルを色付けすることです。パイソンを通じて実装を探しています。
マークSetchell:
あなたはシャープや高コントラストているエッジを、見つけた後、元の画像の上にそれらを重ね合わせることができます。
だから、この画像で始まります。
クレジット:リタKochmarjova - Fotoliaの
できるよ:
#!/usr/bin/env python3
import numpy as np
from PIL import Image, ImageFilter, ImageChops
# Open input image and make greyscale copy
image = Image.open('bulldog.jpg')
grey = image.copy().convert('L')
# Find the edges
edges = grey.filter(ImageFilter.FIND_EDGES)
edges.save('edges.png')
# Draw the sharp edges in white over original
RGBedges = Image.merge('RGB',(edges,edges,edges))
image.paste(RGBedges, mask=edges)
# Save
image.save('result.png')
あなたは、水の端に石に最も明確に効果を見ることができます。
ここでは中間体ですedges.png
。あなたはやや白画素を拡張することができ、またはしきい値より強く規定されて合焦部品を作るために。
エッジはそれらをより明らかにするために少し拡張してここにあります:
#!/usr/bin/env python3
import numpy as np
from PIL import Image, ImageFilter
from skimage.morphology import dilation, square
# Open input image and make greyscale copy
image = Image.open('bulldog.jpg')
grey = image.copy().convert('L')
# Find the edges
edges = grey.filter(ImageFilter.FIND_EDGES)
# Define a structuring element for dilation
selem = square(3)
fatedges = dilation(np.array(edges),selem)
fatedges = Image.fromarray(fatedges)
fatedges.save('edges.png')
# Draw the sharp edges in white over original
RGBedges = Image.merge('RGB',(fatedges,fatedges,fatedges))
image.paste(RGBedges, mask=fatedges)
# Save
image.save('result.png')
あなたはまた、とターミナルでそれを行うことができますImageMagickの任意のコードを記述せず:
magick bulldog.jpg \( +clone -canny 0x1+10%+30% \) -compose overlay -composite result.png
それともこれは、これは、Pythonにもっと似ています。
magick bulldog.jpg \( +clone -canny 0x1+10%+30% \) -compose lighten -composite result.png