Created
February 6, 2015 08:42
-
-
Save RH2/e2b53cfb428b6518f41c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import mathutils | |
import random | |
import copy | |
print("running") | |
a=mathutils.Color() | |
a.hsv=[0.2,0,1] | |
D=bpy.data | |
img=bpy.data.images["image"] | |
img_width=img.size[0] | |
img_height=img.size[1] | |
temp = [None] * img_width*img_height*4 | |
for row in range(img_width): | |
indexAdd=(row*4*img_width) | |
for col in range(img_height): | |
if(random.random()>0): | |
temp[indexAdd+(col*4)+0]=random.random() | |
temp[indexAdd+(col*4)+1]=random.random() | |
temp[indexAdd+(col*4)+2]=random.random() | |
#temp[indexAdd+(col*4)+0]=a.r | |
#temp[indexAdd+(col*4)+1]=a.g | |
#temp[indexAdd+(col*4)+2]=a.b | |
temp[indexAdd+(col*4)+3]=1.0 | |
else: | |
temp[indexAdd+(col*4)+0]=0.0 | |
temp[indexAdd+(col*4)+1]=0.0 | |
temp[indexAdd+(col*4)+2]=0.0 | |
temp[indexAdd+(col*4)+3]=1.0 | |
img.pixels=temp | |
coverageMap = [0] *(img_width*img_height) | |
for row in range(img_width): | |
indexAdd=(row*4*img_width) | |
for col in range(img_height): | |
if(random.random()>0.75): | |
tempColor = mathutils.Color() | |
#tempColor = [temp[indexAdd+(col*4)+0],temp[indexAdd+(col*4)+1],temp[indexAdd+(col*4)+2]] | |
tempColor.r = copy.copy(temp[indexAdd+(col*4)+0]) | |
tempColor.g = copy.copy(temp[indexAdd+(col*4)+1]) | |
tempColor.b = copy.copy(temp[indexAdd+(col*4)+2]) | |
coverageMap[row*img_width+col]=copy.copy(tempColor.h) | |
coverageSum=0 | |
for i in range(img_width*img_height): | |
print(coverageMap[i]) | |
coverageSum+=coverageMap[i] | |
print("coverage average is:"+str(coverageSum/(img_width*img_height))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment