python rgb2gray_Python color.rgb2grey方法代碼示例

# 需要導入模塊: from skimage import color [as 別名]

# 或者: from skimage.color import rgb2grey [as 別名]

def analyze_image(args):

"""Analyze all wells from all trays in one image."""

filename, config = args

LOGGER.debug(filename)

rows = config["rows"]

columns = config["columns"]

well_names = config["well_names"]

name = splitext(basename(filename))[0]

if config["parse_dates"]:

try:

index = convert_to_datetime(fix_date(name))

except ValueError as err:

return {"error": str(err), "filename": filename}

else:

index = name

try:

image = rgb2grey(imread(filename))

except OSError as err:

return {"error": str(err), "filename": filename}

plate_images = cut_image(image)

data = dict()

for i, (plate_name, plate_image) in enumerate(

zip(config["plate_names"], plate_images)):

plate = data[plate_name] = dict()

plate[config["index_name"]] = index

if i // 3 == 0:

calibration_plate = config["left_image"]

positions = config["left_positions"]

else:

calibration_plate = config["right_image"]

positions = config["right_positions"]

try:

edge_image = canny(plate_image, CANNY_SIGMA)

offset = align_plates(edge_image, calibration_plate)

# Add the offset to get the well centers in the analyte plate

well_centers = generate_well_centers(

np.array(positions) + offset, config["plate_size"], rows,

columns)

assert len(well_centers) == rows * columns

plate_image /= (1 - plate_image + float_info.epsilon)

well_intensities = [find_well_intensity(plate_image, center)

for center in well_centers]

for well, intensity in zip(well_names, well_intensities):

plate[well] = intensity

except (AttributeError, IndexError) as err:

return {"error": str(err), "filename": filename}

return data

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值