0
$\begingroup$

I was wondering if there is some method in blender to make all the edges of the frames in an animation blend to a singular color so that it can be used on a website with one solid color and blend seamlessly into the website. For example, I have this video here: https://halokeys.com/static/media/elemental75_framed.mp4. The edge frames all have a very similar color but they very slightly especially as the frame changes so it doesn't blend into a solid color website. I have thought about using a transparent background, but the problem is I need to also catch emissions from the keyboard in the video (led lights) which need a surface to project on.

It is easier with single frame renders as I can render the plane on which the keyboard rests as solid black and the reflections of the LED lights don't extend to the border so the border pixels are all black. I then use a python program to replace all black pixels (or near black pixels) to transparent pixels. Since the LED light color is blue, I can then use some math to detect what percentage of 255 blue the pixel is and set the pixel color to 255 blue but decrease the transparency so that it matches the original pixel.

The program looks like so:


img = Image.open('image.png') # replace image with file name
max_b = 255

img = img.convert("RGBA")
datas = img.getdata()


newData = []
for item in datas:
    r = item[0]
    g = item[1]
    b = item[2]

    if b == 0 or (r + g + b) <= 3: # sets inconsistent 1, 1, 1 pixels as transparent
        newData.append((0, 0, 0, 0)) # This is for checking black pixels, replace transparent. Do
        # if item[3] == 0 to check for transparent pixels.
    else: 
        transparency = b / max_b
        offset = 1 / transparency # b CANNOT == 0 because you can't divide by 0
        new_r = round(offset * r)
        new_g = round(offset * g)
        transparency = round(transparency * 255) # converts 0-1 to 0-255
        newData.append((new_r, new_g, max_b, transparency))
        print((new_r, new_g, max_b, transparency))


img.putdata(newData)
img.save("img2.png", "PNG")

However, I obviously can't do this for video as it would take way too long so I'm trying to figure out if there is some method in blender so catch emissions with a transparent background or at least have a video with a solid color frame throughout the video so that it works well with my website. Thanks.

$\endgroup$

1 Answer 1

0
$\begingroup$

Nice render. In my mind, this can be solved through compositing. By using a grayscale image as a mask we can mask out the edges of your render and place it on any colour we like, or leave it transparent if that's more convenient.

To leave it transparent the 'Alpha Over'-node in this setup can be removed from it. If the solution has to be in python I apologize for wasting your time.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .