def main(filename_input, filename_output):
    KERNAL_SIZE = 1
    MODE = "median"
    image = cv2.imread(filename_input, 0)
    processed_image = kernal_image(image, KERNAL_SIZE, MODE)
    processed_image = text(processed_image, "Median Filter")
    cv2.imwrite(filename_output, processed_image)
def cross_fade(filename_left, filename_right, filename_out, window_size):
    left_image = prepare_image(filename_left)
    right_image = prepare_image(filename_right)

    left_width, left_height = left_image.shape
    right_width, right_height = right_image.shape

    if left_height != left_width and right_height != right_width:
        raise ValueError("Doesn't support non square images. Meh.")

    if left_height != right_height and left_width != right_width:
        raise ValueError("Width and height of each image must be equal.")

    left_linear_weight = generate_cross_fade(window_size=window_size,
                                             image_size=left_width)
    right_linear_weight = generate_cross_fade(window_size=window_size,
                                              image_size=right_width,
                                              reverse=True)

    left_image = left_image * left_linear_weight
    right_image = right_image * right_linear_weight

    merged = left_image + right_image
    merged2 = text(merged, "Cross Fade")
    cv2.imwrite(filename_out, merged2)
Esempio n. 3
0
def edge_detection(filename_input, filename_output, edge_threshold):
    image = cv2.imread(filename_input, 0)
    image_width, image_height = image.shape

    y = np.zeros((image_width - 1, image_height))
    for row_index in range(0, len(image) - 1):
        y[row_index] = image[row_index + 1, :] - image[row_index, :]

    x = np.zeros((image_width, image_height - 1)).T
    for column_index in range(0, len(image) - 1):
        x[column_index] = image[:, column_index + 1] - image[:, column_index]

    x = x.T
    x_width, x_height = x.shape
    y_width, y_height = y.shape

    output_width = min(x_width, y_width)
    output_height = min(x_height, y_height)

    subset_y = y[0:output_width, 0:output_height]
    subset_x = x[0:output_width, 0:output_height]

    magnitude = (subset_x**2 + subset_y**2)**0.5
    magnitude = np.where(magnitude > edge_threshold, 0, 255).astype(int)
    magnitude = text(magnitude, "Edge Detection")
    cv2.imwrite(filename_output, magnitude)
Esempio n. 4
0
		x[...] = (x-25+twave*25)/(1.3-twave*0.3)




if __name__ == "__main__":
	screen = pygame.display.set_mode([640,320])
	clock = pygame.time.Clock()
	print screen.get_bitsize()
	t = 0
	while 1:
		t += 100
		for event in pygame.event.get():
			if event.type == pygame.QUIT: sys.exit()

		array = []
		screen.fill([200,200,200])

		u.circle(screen,(100,100,100),[50,50],50)

		clock.tick()
		u.text(screen,10,10,"FPS: %.1f" % clock.get_fps(),(150,150,150))



		array = [pygame.surfarray.pixels_red(screen),pygame.surfarray.pixels_green(screen),pygame.surfarray.pixels_blue(screen)]

		filter(array,t)
		#pygame.surfarray.blit_array(screen,array)
		pygame.display.flip()
Esempio n. 5
0
			d.draw(surf)
			if d.t == int(d.r * 7) and random.random() < 0.5 and d.r > 2:
				if len(self.dots) < 40:
					self.dots.append(Dot(d.x,d.y,0,d.r*(0.5+0.7*random.random()),-d.adir,self.color))
					
			if random.random() < 0.02 and d.r*50 > d.t > d.r * 6 and d.f < d.r/5 and d.r > 3:
				if len(self.dots) < 40:
					self.dots.append(Dot(d.x,d.y,0.5*(random.random()-0.5),d.r*(0.5+0.6*random.random()),-d.adir,self.color))
					d.f += 1
			
			
			if abs(d.t) > d.r*50:
				self.dots.remove(d)
				if len(self.dots) < 1:
					self.dots.append(Dot(d.x,d.y,0.5*(random.random()-0.5),d.r*(0.5+0.6*random.random()),-d.adir,self.color))
		
					

		
if __name__ == "__main__":
	screen = pygame.display.set_mode([640,320])
	screen.fill([240,240,240])
	vine = Vine(0,160)
	while 1:
		for event in pygame.event.get():
			if event.type == pygame.QUIT: sys.exit()
		u.text(screen,20,160+5,"Loading... ",(180,180,180))
		#screen.fill([240,240,240])	
		vine.grow(screen)
		pygame.display.flip()
Esempio n. 6
0
        x[...] = (x - 25 + twave * 25) / (1.3 - twave * 0.3)


if __name__ == "__main__":
    screen = pygame.display.set_mode([640, 320])
    clock = pygame.time.Clock()
    print screen.get_bitsize()
    t = 0
    while 1:
        t += 100
        for event in pygame.event.get():
            if event.type == pygame.QUIT: sys.exit()

        array = []
        screen.fill([200, 200, 200])

        u.circle(screen, (100, 100, 100), [50, 50], 50)

        clock.tick()
        u.text(screen, 10, 10, "FPS: %.1f" % clock.get_fps(), (150, 150, 150))

        array = [
            pygame.surfarray.pixels_red(screen),
            pygame.surfarray.pixels_green(screen),
            pygame.surfarray.pixels_blue(screen)
        ]

        filter(array, t)
        #pygame.surfarray.blit_array(screen,array)
        pygame.display.flip()