mirror of
				https://github.com/stevenrobertson/cuburn.git
				synced 2025-11-04 02:10:45 -05:00 
			
		
		
		
	A fake log filter stage while I work on other stuff
This commit is contained in:
		
							
								
								
									
										15
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main.py
									
									
									
									
									
								
							@ -40,11 +40,16 @@ def main(args):
 | 
				
			|||||||
    anim = Animation(genomes)
 | 
					    anim = Animation(genomes)
 | 
				
			||||||
    anim.compile()
 | 
					    anim.compile()
 | 
				
			||||||
    bins = anim.render_frame()
 | 
					    bins = anim.render_frame()
 | 
				
			||||||
    #bins = np.log2(bins + 1)
 | 
					
 | 
				
			||||||
    alpha = [bins[y][x][3] for x in range(anim.features.hist_width)
 | 
					    # Embarrassingly poor (and s-l-o-w) approximation of log filtering, because
 | 
				
			||||||
                           for y in range(anim.features.hist_height)]
 | 
					    # I want to keep working on performance right now
 | 
				
			||||||
    print sum(alpha)
 | 
					    alpha = np.array([[bins[y][x][3] for x in range(anim.features.hist_width)]
 | 
				
			||||||
    bins *= (512./(np.mean(alpha)+1e-9))
 | 
					                                    for y in range(anim.features.hist_height)])
 | 
				
			||||||
 | 
					    k2ish = (256./(np.mean(alpha)+1e-9))
 | 
				
			||||||
 | 
					    lses = 20 * np.log2(1.0 + alpha * k2ish) / (alpha+1e-6)
 | 
				
			||||||
 | 
					    for x in range(anim.features.hist_width):
 | 
				
			||||||
 | 
					        for y in range(anim.features.hist_height):
 | 
				
			||||||
 | 
					            bins[y][x] *= lses[y][x]
 | 
				
			||||||
    bins = np.minimum(bins, 255)
 | 
					    bins = np.minimum(bins, 255)
 | 
				
			||||||
    bins = bins.astype(np.uint8)
 | 
					    bins = bins.astype(np.uint8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user