在抗生素测定中发现杀伤区,区域之间的对比度低

时间:2015-12-08 17:01:20

标签: python opencv numpy matplotlib

这是对培养皿的抗生素测定:

Antibiotic Assay on Petri Dish

我正在开展一个项目,我正在自动阅读培养皿类抗生素检测。在这些测试中,来自患者的细菌散布在培养皿上并使其生长成“细菌草坪”。一旦细菌覆盖培养皿的整个表面,就将不同药物类型或相同药物但不同浓度的药丸放在培养皿上,24小时后测量杀灭区(如果存在的话)。杀戮区代表药物从药丸中杀死一些半径的区域。杀灭区的半径有多大决定了细菌是否对药物敏感或耐药,以及不同的浓度。

我一直在文件中使用20个图像的训练集来概括我的结果。我一直在使用opencvskimagenumpyscipymatplotlib python库来构建此程序。到目前为止,我已经能够通过霍夫圆形取景器和图像的形态梯度变换准确地识别培养皿边缘。我也能够使用SURF来识别图像中药丸的位置。

我的问题: 问题是杀戮区边缘和细菌草坪之间没有足够的对比来使用HoughCircleFinder找到这些圆形区域。谁能帮我找到准确识别这些杀戮区的方法呢?

import numpy as np
import cv2
from skimage import io,img_as_float
from matplotlib import pyplot as plt
import os
from skimage.util import img_as_ubyte
from skimage.color import rgb2gray
from skimage.filters import sobel
import matplotlib.patches as patches
import matplotlib.cbook as cbook
from skimage.filters.rank import entropy
from skimage.morphology import disk
from skimage import io,exposure
from skimage.segmentation import slic
from skimage import io, segmentation
from skimage.color import label2rgb,rgb2gray
from scipy import signal
import scipy
from skimage.future import graph
from skimage.feature import peak_local_max


def HoughCircleFinder(filtered_image,image):
    output = image.copy()
    gray = img_as_ubyte(filtered_image)
#   gray = cv2.cvtColor(img_as_ubyte(image), cv2.COLOR_BGR2GRAY)

    # detect circles in the image
    circles = cv2.HoughCircles(gray, cv2.cv.CV_HOUGH_GRADIENT, 5, minDist = int(0.45 * max(image.shape)), minRadius = int(0.25 * max(image.shape)), maxRadius = int(0.6 * max(image.shape)))

    # ensure at least some circles were found
    if circles is not None:
        # convert the (x, y) coordinates and radius of the circles to integers
        circles = np.round(circles[0, :]).astype("int")
        # loop over the (x, y) coordinates and radius of the circles
        for (x, y, r) in circles:
            print x,y,r
            # draw the circle in the output image, then draw a rectangle
            # corresponding to the center of the circle
            # filter circles that go out of view of image
            if not (image.shape[0]*0.25) < x < (image.shape[0]*0.75):
                continue
            elif not (image.shape[0]*0.25) < y < (image.shape[0]*0.75):
                continue
            else:
#               output = CropCircle(output,x,y,r)
                cv2.circle(output, (x, y), r, (0, 255, 0), 4)
                cv2.rectangle(output, (x - 5, y - 5), (x + 5, y + 5), (0, 128, 255), -1)
        return output

def MorphologicalGradient(img):
    kernel = np.ones((7,3),np.uint8)
#   kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
    gradient = cv2.morphologyEx(img, cv2.MORPH_GRADIENT, kernel)
    return gradient

def SURF(img): #image1
    featurels = []
    surf = cv2.SURF(7000)
    kp, des = surf.detectAndCompute(img,None)
    for i in kp:
#       print round(i.pt[0])
        featurels.append(i.pt)
    surf.hessianThreshold = 50000
    img2 = cv2.drawKeypoints(img,kp,None,(255,0,0),4)
    return img2,featurels


# make list of images from file

pic_list = [os.path.join("/Users/sethcommichaux/Desktop/PetriKillZone/PetriDishes/",pic) for pic in os.listdir("/Users/sethcommichaux/Desktop/PetriKillZone/PetriDishes/")]

# for loop for processing images and getting useful data
for image in pic_list[1:]:
    print image
    image1 = cv2.imread(image,0) #grayscale image
    image = cv2.imread(image) #color image
    print "number of pixels in image: ",image.size
    print "image shape (if grayscale will be 2 tuple, if color 3 or more): ", image.shape
    image = HoughCircleFinder(MorphologicalGradient(image1),image)
    print 'image data type: ',image.dtype
    plt.figure()
    io.imshow(image)
    plt.show()
    # part that finds pills
    image,features = SURF(image)
    plt.figure()
    io.imshow(image)
    plt.show()

我已经使用SURF关键点对象来识别药丸的位置,但是如何找到我不知所措的杀戮区域。下面是从药丸中获取x轴的直方图和直方图的代码。

for row in features:
    PeakFind(image[round(row[1])])
    print image[round(row[1])]
    plt.figure()
    plt.plot(range(len(image[round(row[1])])),image[round(row[1])])
    plt.show()
#   plt.figure()
#   x = plt.hist(image[round(row[0])])
print features

0 个答案:

没有答案