当前位置: 首页>>代码示例>>Python>>正文


Python Parameters.setImageSize方法代码示例

本文整理汇总了Python中parameters.Parameters.setImageSize方法的典型用法代码示例。如果您正苦于以下问题:Python Parameters.setImageSize方法的具体用法?Python Parameters.setImageSize怎么用?Python Parameters.setImageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parameters.Parameters的用法示例。


在下文中一共展示了Parameters.setImageSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: countRegions

# 需要导入模块: from parameters import Parameters [as 别名]
# 或者: from parameters.Parameters import setImageSize [as 别名]
def countRegions():
    # Requires: -the first command line argument is the name of the
    #            image to be segmented
    #           -the second command line argument is the color space being
    #            used, either RGB, HSV, or HLS
    # Effects: -calls closure with count foreground argument on, returns
    #           count of distinct foreground objects
    
    colorSpace = argv[2].lower()
    
    if not (colorSpace in ["rgb", "hsv", "hls"]):
        print "Second argument not one of RGB, HSV, or HLS"
        print "The first argument should be the name of the image to be segmented"
        print "Followed by the desire color space representation"
        exit(1)
    
    try:
        image = Image.open(argv[1])
        imageData = colorSpaceConvert(list(image.getdata()), argv[2].lower())
    except:
        print "Invalid or no image name given"
        print "The first argument should be the name of the image to be segmented"
        print "Followed by the desire color space representation"
        exit(1)
        
    if colorSpace == "rgb":
        redMinMax = raw_input("Red min-max, between 0 and 255: ")
        greenMinMax = raw_input("Green min-max, between 0 and 255: ")
        blueMinMax = raw_input("Blue min-max, between 0 and 255: ")
        redMinMax = [float(x) / 255.0 for x in redMinMax.split()]
        greenMinMax = [float(x) / 255.0 for x in greenMinMax.split()]
        blueMinMax = [float(x) / 255.0 for x in blueMinMax.split()]
        colorRanges = [redMinMax, greenMinMax, blueMinMax]
    elif colorSpace == "hsv":
        hueMinMax = raw_input("Hue min-max, between 0 and 360: ")
        satMinMax = raw_input("Saturation min-max, between 0 and 100: ")
        valMinMax = raw_input("Value min-max, between 0 and 100: ")
        hueMinMax = [float(x) / 360.0 for x in hueMinMax.split()]
        satMinMax = [float(x) / 100.0 for x in satMinMax.split()]
        valMinMax = [float(x) / 100.0 for x in valMinMax.split()]
        colorRanges = [hueMinMax, satMinMax, valMinMax]
    else:
        hueMinMax = raw_input("Hue min-max, between 0 and 360: ")
        lightMinMax = raw_input("Lightness min-max, between 0 and 100: ")
        satMinMax = raw_input("Saturation min-max, between 0 and 100: ")
        hueMinMax = [float(x) / 360.0 for x in hueMinMax.split()]
        lightMinMax = [float(x) / 100.0 for x in lightMinMax.split()]
        satMinMax = [float(x) / 100.0 for x in satMinMax.split()]
        colorRanges = [hueMinMax, lightMinMax, satMinMax]
    
    param = Parameters()
    param.setImageSize(image.size)
    param.setColorRanges(colorRanges)
    
    seg = segmentation.colorSegmenter()
    mask = seg.segmentImage(imageData, param, True)
    
    close = closure.closure()
    close.segmentRegions(mask, param, 0, True, False)
开发者ID:Ali09,项目名称:image-segmentation,代码行数:61,代码来源:count.py


注:本文中的parameters.Parameters.setImageSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。