ColorSelector.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:SelfDrivingCar 作者: aguijarro 项目源码 文件源码
def ColorSelector():
    # Read in the image and print out some stats
    image = (mpimg.imread('test.png') * 255).astype('uint8')
    print('This image is: ', type(image),
          'with dimensions:', image.shape)

    # Grab the x and y size and make a copy of the image
    ysize = image.shape[0]
    xsize = image.shape[1]
    color_select = np.copy(image)

    # Define color selection criteria
    # MODIFY THESE VARIABLES TO MAKE YOUR COLOR SELECTION
    red_threshold = 200
    green_threshold = 200
    blue_threshold = 200

    rgb_threshold = [red_threshold, green_threshold, blue_threshold]
    print('Esta es la variable rgb_threshold: ', rgb_threshold)

    # Do a bitwise or with the "|" character to identify
    # pixels below the thresholds
    thresholds = (image[:, :, 0] < rgb_threshold[0]) \
                  | (image[:, :, 1] < rgb_threshold[1]) \
                  | (image[:, :, 2] < rgb_threshold[2])

    print('Esta es la variable thresholds: ', thresholds)

    color_select[thresholds] = [0, 0, 0]
    # plt.imshow(color_select)

    # Uncomment the following code if you are running the code
    # locally and wish to save the image
    mpimg.imsave("test-after.png", color_select)

    # Display the image
    plt.imshow(color_select)
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号