def main():
   try:
      image = Image.open(argv[1])
      #image = cv2.imread(argv[1])
   except:
      image = openImage()
   #Calling edgedetection with an image as argument returns a histogram with the frequencies
   #magnitudes, pixelsorientation = edgedetection(image)
   #hist, bins = np.histogram(magnitudes.values(), bins=10)
   #width = 0.7 * (bins[1]-bins[0])
   #center = (bins[:-1] + bins[1:])/2
   #threshold = delimitthreshold(magnitudes)
   #edgedetection draws a new image if threshold is given
   #edgedetection(image, threshold)
   edgedetect(image)
示例#2
0
        if nbh == '8':
            for x in xrange(0, width):
                for y in xrange(0, height):
                    rlist = []
                    glist = []
                    blist = []
                    for i in [-1, 0, 1]:
                        for j in [-1, 0, 1]:
                            if x + i >= 0 and x + i < width and y + j >= 0 and y + j < height:
                                r, g, b = pixels[x + i, y + j]
                                rlist.append(r)
                                glist.append(g)
                                blist.append(b)
                    rmax = max(rlist)
                    gmax = max(glist)
                    bmax = max(blist)
                    pixels[x, y] = (rmax, gmax, bmax)

    #newimage.save('newimage.png')
    #newimage.show()
    return pixels


if __name__ == '__main__':
    try:
        # Call filter with image and filter as args
        image = Image.open(argv[1])
        filter(image, argv[2], argv[3])
    except:
        filter(openImage())
    holes = list()
    visited = list()
    for x in xrange(0, width):
        for y in xrange(0, height):
            if (x, y) not in visited and pixels2[x, y] == (0, 255, 0):
                s_visited = dfs((x, y), pixels2, visited, width, height,
                                hole_pixels)
                print s_visited
                print
                holes.append(s_visited)
                visited.extend(s_visited)
            visited.append((x, y))

    print len(holes)

    colors = color(len(holes))
    i = 0
    for hole in holes:
        holes_in_original = drawbox(holes_in_original, hole, colors[i])
        i += 1
    holes_in_original.save("HolesOutput.png")


if __name__ == '__main__':
    try:
        image = Image.open(argv[1]).convert("RGB")
    except:
        image = openImage().convert("RGB")
    holedetection(image)
示例#4
0
            for x in xrange(0, width * factor):
                j = 0
                for y in xrange(0, height * factor):
                    newimage.putpixel((x, y), pixels[i, j])
                    if y % factor + 1 == factor:
                        j += 1
                if x % factor + 1 == factor:
                    i += 1
            newimage.save('enlarged.png')
            newimage.show()

    # Shrink


#   elif enorshrink=='s':

if __name__ == '__main__':
    try:
        image = Image.open(argv[1])
    except:
        image = openImage()
    try:
        enorshrink = argv[2]
    except:
        enorshrink = raw_input("Enlarge[e], shrink[s]: ")
    try:
        mode = argv[3]
    except:
        mode = raw_input("Proportional[p], Arbitrary[a]: ")
    resize(image, enorshrink, mode)