Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当背景在角色后面着色时,skimage regionprops不会分割角色_Python_Ocr_Scikit Image - Fatal编程技术网

Python 当背景在角色后面着色时,skimage regionprops不会分割角色

Python 当背景在角色后面着色时,skimage regionprops不会分割角色,python,ocr,scikit-image,Python,Ocr,Scikit Image,我试图制作一个ANPLR系统,但我的车牌示例(以及我国的许多车牌)在车牌字符背后有一种背景,下面是一个示例 在制作了一个阈值_-otsu滤波器之后 threshold_value = threshold_otsu(gray_car_image) binary_car_image = gray_car_image > threshold_value 和区域道具 for i in range(len(cca2.plate_like_objects)): license_plate

我试图制作一个ANPLR系统,但我的车牌示例(以及我国的许多车牌)在车牌字符背后有一种背景,下面是一个示例

在制作了一个阈值_-otsu滤波器之后

threshold_value = threshold_otsu(gray_car_image)
binary_car_image = gray_car_image > threshold_value
和区域道具

for i in range(len(cca2.plate_like_objects)):
    license_plate = np.invert(cca2.plate_like_objects[i])
    labelled_plate = measure.label(license_plate, background=0, connectivity=1)
    fig, ax1 = plt.subplots(1)
    ax1.imshow(license_plate, cmap="gray")
    character_dimensions = (k1, k2, k3, k4)
    min_height, max_height, min_width, max_width = character_dimensions
    characters = []
    counter=0
    column_list = []
    for regions in regionprops(labelled_plate):
        y0, x0, y1, x1 = regions.bbox[0] ,regions.bbox[1],regions.bbox[3], regions.bbox[4]
        region_height = y1 - y0
        region_width = x1 - x0
        if region_height > min_height and region_height < max_height and region_width > min_width and region_width < max_width:
            roi = license_plate[y0:y1, x0:x1]
            rect_border = patches.Rectangle((x0, y1), x1 - x0, y1 - y0, edgecolor="red",                  linewidth=2, fill=False)
            ax1.add_patch(rect_border)
            resized_char = resize(roi, (40, 80))
            characters.append(resized_char)
            column_list.append(x0)
    plt.show()
而不是大津

我得到了另一个字符的识别,但我仍然有“2”的分割出来,任何帮助将是惊人的,这里是板块


您是否尝试过形态操作,如打开、关闭、腐蚀、扩张。此外,您可以运行高斯中值滤波器作为平滑的第一步。这些字符比背景颜色暗。我会尝试一种不同于大津的阈值方法。还有
skimage.filters.try_all_threshold
来检查最好的一个。最后,我在阈值之前使用了一些放大和模糊来解决这个问题,你有没有尝试过像打开、关闭、腐蚀、放大这样的形态学操作。此外,您可以运行高斯中值滤波器作为平滑的第一步。这些字符比背景颜色暗。我会尝试一种不同于大津的阈值方法。还有
skimage.filters。请尝试\u all\u threshold
检查最佳阈值。最后,我在阈值之前使用了一些放大和模糊来解决这个问题,
threshold_value = threshold_niblack(gray_car_image)
binary_car_image = gray_car_image > threshold_value