小编the*_*n.a的帖子

将图像特定区域的像素设为空白或用任何颜色填充该区域

我以为我可以自己做!

所以,我一直在做我的一个项目,我需要在图像中找到一个/多个对象(目前,我使用的是简单的模板匹配)。

当找到一个对象时,我想删除该区域的像素并使该区域透明或用任何颜色填充它。

例如,我有这个图像(我想找到的地方the coke bottle cane):-

image_before

运行对象检测脚本后,我有:-

After_image

您可以在红色矩形内看到匹配的对象!

现在,我想要做的是删除这个矩形区域并使其透明或用任何颜色填充它!

我尝试了很多东西,仍在尝试,但没有运气。这是我到目前为止所拥有的:

import numpy as np
import argparse
import imutils
import glob
import cv2
from matplotlib import pyplot as plt


ap = argparse.ArgumentParser()
ap.add_argument("-t", "--template", required=True, help="Path to template image")
ap.add_argument("-i", "--images", required=True,
    help="Path to images where template will be matched")
ap.add_argument("-v", "--visualize",
    help="Flag indicating whether or not to visualize each iteration")
args = vars(ap.parse_args())

def match_and_count(template, image):
    img_rgb = cv2.imread(image)
    img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
    template = cv2.imread(template,0)
    w, …
Run Code Online (Sandbox Code Playgroud)

python opencv image-processing python-imaging-library python-3.x

3
推荐指数
1
解决办法
980
查看次数

没有名为“nltk”的模块

我成功安装nltk并且工作正常。我必须运行一个nltk导入的文件和张量流,因此,我必须激活tensorflow

当我激活tensorflow我想运行的 .py 文件时出现错误。我已经阅读了一些解决方案,但它们没有帮助。

HP-250-G5-Notebook-PC:~$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>> 
Run Code Online (Sandbox Code Playgroud)

这工作正常,但事实并非如此

(tensorflow)HP-250-G5-Notebook-PC:~/AIG2018/Chatbot$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Run Code Online (Sandbox Code Playgroud)

我在做什么? …

python nltk tensorflow

1
推荐指数
1
解决办法
2万
查看次数