Log in

View Full Version : Strange color artifacts with Overlay()


2E7AH
27th December 2009, 09:34
Consider this code, which doesn't make sense but I simplified larger code as I could:

file = AviSource("clip.avi", audio=false)
drop = ImageSource("empty.png", pixel_type="rgb32")

y = Height(file)

Overlay(BlankClip(file, Height = 7*y, Width = Width(file), color=$ffffff), drop)

Layer(Trim(file,434,0),"add",256,0,0)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

Layer(Trim(file,434,0),"add",256,0,y)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

Layer(Trim(file,434,0),"add",256,0,2*y)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

Layer(Trim(file,434,0),"add",256,0,3*y)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

Layer(Trim(file,434,0),"add",256,0,4*y)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

Layer(Trim(file,434,0),"add",256,0,5*y)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

Layer(Trim(file,434,0),"add",256,0,6*y)
Overlay(drop, 0, 0, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

where empty.png is png with transparency

Result:
http://img138.imageshack.us/img138/6296/clipboard01n.th.png (http://img138.imageshack.us/img138/6296/clipboard01n.png)

Now, if we use this only once:

Layer(Trim(file,434,0),"add",256,0,0)
Overlay(drop, 6, 3, mask=ShowAlpha(Mask(drop, drop.ShowAlpha(pixel_type="rgb32"))))

it's almost like nothing happened, but as we repeat that function, the ugly artifact grows on and on.

Can someone tell me why is this happening?

Thanks

Dark Shikari
27th December 2009, 09:36
Looks like artifacts from repeated colorspace conversion maybe?

2E7AH
27th December 2009, 09:57
Thanks for the fast response :)

I don't know if I understand you right: there is no conversion in above example code, and it happens with any clip I try
Here is another example (I needed to use ConvertToRGB here for the clip source as it is in YUY2)

http://img63.imageshack.us/img63/9947/crashf.th.png (http://img63.imageshack.us/img63/9947/crashf.png)

How can I avoid this?

wonkey_monkey
27th December 2009, 12:37
Overlay converts to YUV internally, so maybe it's compound rounding errors?

David

2E7AH
28th December 2009, 13:15
So it seems that using Overlay() more than once in the same scene is not good idea
I managed to use Layer() instead

Thanks for explanations