小编use*_*904的帖子

找到图像中的所有圆圈

我是python和图像处理的新手.我正在做一个爱好项目,我想在其中找到图像中的所有圆圈,然后找出哪一个在其中标记了交叉('X').到目前为止,我已经将一些代码放在一起找到了圆圈(下图).它适用于一个图像,但无法识别另一个图像上的所有圆圈.请指导我如何提高find_circles算法的性能.

测试图像:

测试图像

结果图:

结果图像

import cv2
import cv
import numpy as np
import operator
from PIL import Image

def find_circles(img):
    im_gray = cv2.imread(img, cv2.CV_LOAD_IMAGE_GRAYSCALE)
    (thresh, im_bw) = cv2.threshold(im_gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
    img_bw = cv2.threshold(im_gray, thresh, 255, cv2.THRESH_BINARY)[1]
    cv2.imwrite('img_bw.png',img_bw)
    rows, cols =img_bw.shape
    circles = cv2.HoughCircles(img_bw,cv.CV_HOUGH_GRADIENT,1,rows/32, param1=100,param2=40,minRadius=0,maxRadius=100)
    circles = np.uint16(np.around(circles))
    return circles

def draw_circles(img, circles):
    img = cv2.imread(img,0)
    cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
    for i in circles[0,:]:
    # draw the outer circle
        cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
        # draw the center of the circle
        cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
        cv2.putText(cimg,str(i[0])+str(',')+str(i[1]), (i[0],i[1]), …
Run Code Online (Sandbox Code Playgroud)

python opencv

5
推荐指数
1
解决办法
4323
查看次数

使用opencv删除圆圈

我正在研究 opencv 问题来找出哪些圆圈被填充。然而,有时圆圈的边缘是误报的原因。我想知道是否可以通过将 RGB 中具有高 R 值的所有像素变成白色来删除这些圆圈。我的方法是创建一个粉红色的像素蒙版,然后从原始图像中减去蒙版以删除圆圈。截至目前,我正在戴黑色面具。我做错事了。请指导。

    rgb = cv2.imread(img, cv2.CV_LOAD_IMAGE_COLOR)
    rgb_filtered = cv2.inRange(rgb, (200, 0, 90), (255, 110, 255))
    cv2.imwrite('mask.png',rgb_filtered) 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python opencv image-processing omr

5
推荐指数
2
解决办法
7369
查看次数

上传前调整图片大小

我正在整理 HTML+JS 代码以在自动将表单提交到服务器之前调整图片大小。我最初编写了用于自动提交表单的代码,然后添加了用于调整图像大小的逻辑。自动表单提交有效,但图像大小调整无效。请提供指导。先感谢您。

<!DOCTYPE html>
<html>
<head>
<title>Flask App</title>    
<meta name="viewport" content="width=device-width, initial-scale=1, user-
scalable=no">  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
<script src="http://malsup.github.com/jquery.form.js"></script> 

<script type="text/javascript">
$(function(){
    //JS Code snippet 1 - Automatic form submission on file selection
    $("#file_select").change(function(){
    $("#upload_form").submit();  
    $("#upload_form_div").hide();
    $("#loading").show();

    //JS Code snippet 2 - Image Resizing
    var filesToUpload = inputs.files;

    var img = document.createElement("img");
    var reader = new FileReader();  
    reader.onload = function(e) {img.src = e.target.result}
    reader.readAsDataURL(file);

    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);

    var MAX_WIDTH = 800;
    var MAX_HEIGHT = 600;
    var …
Run Code Online (Sandbox Code Playgroud)

html iphone jquery image image-resizing

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

标签 统计

opencv ×2

python ×2

html ×1

image ×1

image-processing ×1

image-resizing ×1

iphone ×1

jquery ×1

omr ×1