使用python/PIL的图像轮廓 [英] Image outline using python/PIL

查看:730
本文介绍了使用python/PIL的图像轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张苹果的彩色照片,怎么用python/PIL显示它的轮廓(白色,背景黑色)?

I have a color photo of apple, how can I show only its outline (inside white, background black) with python/PIL?

推荐答案

类似的方法应该起作用.

Something like this should work.

from PIL import Image, ImageFilter

image = Image.open('your_image.png')
image = image.filter(ImageFilter.FIND_EDGES)
image.save('new_name.png') 

如果这样不能满足您的需求,那么您可以尝试使用PIL和Python及其他库来实现Prewitt边缘检测,Sobel边缘检测或Canny边缘检测,请参见相关的

If that doesn't give you the result you are looking for then you try implementing either Prewitt edge detection, Sobel edge detection or Canny edge detection using PIL and Python and other libraries see related question and the following example .

如果您尝试进行粒子检测/分析而不只是边缘检测,则可以尝试使用 py4ij 调用您链接的ImageJ方法,以使您获得相同的结果,或者尝试另一个粒子分析Python库

If you are trying to do particle detection / analysis rather than just edge detection, you can try using py4ij to call the ImageJ method you link to give you expect the same result, or try another Particle Analysis Python library EMAN alternately you can write a Particle detection algorithm using PIL, SciPy and NumPy.

这篇关于使用python/PIL的图像轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆