找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 739|回复: 3
收起左侧

[资源分享] 继续贡献udacity self-driving car课程 (2)

[复制链接]

28

主题

1

精华

204

积分

高级会员

Rank: 3Rank: 3

积分
204
发表于 2-23-2017 12:14 AM | 显示全部楼层 |阅读模式

亲!马上注册或者登录会查看更多内容!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
In the next quiz, I want you to modify the values of the variables red_threshold, green_threshold, and blue_threshold until you are able to retain as much of the lane lines as possible, while getting rid of most of the other stuff. When you run the code in the quiz, your image will be output with an example image next to it. Tweak these variables such that your input image (on the left below) looks like the example image on the right.
   The original image (left), and color selection applied (right).

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np

# Read in the image
image = mpimg.imread('test.jpg')

# 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]

# Do a boolean 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])
color_select[thresholds] = [0,0,0]
plt.imshow(color_select)
# Display the image                 
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.jpg", color_select)

Here's how I did it… I started by just trying some guesses.
Eventually, I found that with red_threshold = green_threshold = blue_threshold = 200, I get a pretty good result, where I can clearly see the lane lines, but most everything else is blacked out.
At this point, however, it would still be tricky to extract the exact lines automatically, because we still have many other pixels detected around the periphery.
   The original image (left), and color selection applied (right).

0

主题

0

精华

7

积分

新米人

Rank: 1

积分
7
发表于 2-23-2017 09:07 AM | 显示全部楼层
楼主lfthwjx帖子好赞~~~
回复 支持 反对

使用道具 举报

0

主题

0

精华

14

积分

新米人

Rank: 1

积分
14
发表于 2-25-2017 10:18 AM 来自美国米群网手机版 | 显示全部楼层
coooool回帖支持!~~~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表