Log in

View Full Version : Censor Pixelation


blazerqb11
5th December 2008, 18:12
I'm trying to censor, by pixelation or blurring, a specific area on the video. I certainly could be wrong, but it seems like all the internal filters apply to the entire video. Does anyone know how to do this, or if it is possible with Avisynth?

Gavino
5th December 2008, 18:37
For a generic way to apply a filter to a specific area, see this post.

blazerqb11
6th December 2008, 01:23
Thanks a lot. I successfully ran a few blur filters on specific sections of the screen with your script, though I don't fully understand everything that it is doing. My problem now is that I need something stronger than blur to successfully censor my video. I currently have to pass it about 40 times before it reaches a passable level of censorship. Is there anything that resembles the type of pixelation you see on censored TV. In case anyone is wondering, this is for comedic value, not practical censoring, so the closer it resembles "cliche" censorship the better.

Comatose
6th December 2008, 01:38
You can achieve that effect using PointResize.
Assuming your resolution is 500x500:
pointresize(20,20)
pointresize(500,500)
The smaller the resolution in the first resize is, the stronger the effect.
The second resize is just there to get you back to the original resolution.

So: FilterPart("""pointresize(20,20).pointresize(width,height)""",[...])
You can also censor a circle shape by creating a circle gradient with GraMaMa, inverting it (I think) and then using that as a mask for mt_merge (mt_merge(pointresize(20,20).pointresize(width,height),GraMaMa().Invert())

blazerqb11
6th December 2008, 08:14
First off let me say thanks to both of you, as your help has been more than excellent. Through little trial and error I got the seemingly more simple PointResize square pixelation to work great; here is the code I used:

function FilterPart(clip c, string filter, int left, int top, int right, int bottom) {
Crop(c, left, top, right, bottom)
filtered = Eval(filter) # using implicit 'last'
return Overlay(c, filtered, x=left, y=top)
}

FilterPart("PointResize(4,16).PointResize(40,102)",154,110,40,102)

With much more trial and error I was finally able to get a semblance of a radial censorship working, however it was more like a circular black gradient with strange temporal eccentricities, than radial pixelation. Here is the code I used for that, I will appreciate any commentary on what I did wrong.

mt_merge(pointresize(4,4).pointresize(20,20),GraMaMa(1,1,154,110,20).Invert())

MadRat
6th December 2008, 09:36
I asked a similar question and also got a slow but effective answer.

http://forum.doom9.org/showthread.php?t=134499

Gavino
6th December 2008, 11:43
With much more trial and error I was finally able to get a semblance of a radial censorship working, however it was more like a circular black gradient with strange temporal eccentricities, than radial pixelation. Here is the code I used for that, I will appreciate any commentary on what I did wrong.

mt_merge(pointresize(4,4).pointresize(20,20),GraMaMa(1,1,154,110,20).Invert())
You need to tell GraMaMa to create a binary mask rather than a gradient. Also, I think you have the parameters wrong. Try:
mt_merge(pointresize(4,4).pointresize(20,20),GraMaMa(1,154,110,20,binarize=true).Invert())

Comatose
6th December 2008, 13:04
*hits head on desk for saying "gradient"*
I didn't remember exactly what I did D:

blazerqb11
7th December 2008, 07:54
You need to tell GraMaMa to create a binary mask rather than a gradient. Also, I think you have the parameters wrong. Try:
mt_merge(pointresize(4,4).pointresize(20,20),GraMaMa(1,154,110,20,binarize=true).Invert())

What version of gramama do I need? I currently have gramama_25_dll_20050127 available from http://avisynth.org/warpenterprises/. It's giving me this error:

Avisynth open failure:
Script error: GraMaMa does not have a named argument "binarize".

Comatose
7th December 2008, 08:40
You need the one from Wilbert's page (http://www.geocities.com/wilbertdijkhof/), which was linked in the thread MadRat linked :p

blazerqb11
7th December 2008, 10:52
Ahh, alrite. Now I'm close, yet seemingly back to where I started. Using this code:

mt_merge(pointresize(56,40).PointResize(512,384),GraMaMa(1,176,150,52,binarize=true).Invert())

I was able to sucessfully blur a circular region, however if I lower the arguments of the first pointresize any further, in order to intensify the blur, it seems like the picture seems to "leak" through effectively making the bluring less. I guess it is sufficent though, it just makes me wonder if it will be sufficient for all sources.

The real problem now is that I don't seem to be able to apply this to a specific frame set of the video. If I used the Trim function and apply it using a period e.g.:

videoa = Trim(0,942)
videob = Trim(943,977).mt_merge(pointresize(56,40).PointResize(512,384),GraMaMa(1,176,150,52,binarize=true).Invert())
videoc = Trim(978,0)

videoa ++ videob ++ videoc

Where videob is the section of video I intend to apply the filter to, instead of correctly applying the filter, it apply's a blured portion of the first frame of the video, meaning that it looks like a gigantic color mess. I would guess that I need to insert the Trim fuction into the code somewhere but I keep getting invalid argument errors.

Gavino
7th December 2008, 11:25
You need to do it like this

videob = Trim(943,977)
videob = videob.mt_merge(videob.pointresize(56,40).PointResize(512,384), GraMaMa(1,176,150,52,binarize=true).Invert())

Gavino
7th December 2008, 15:01
I was able to sucessfully blur a circular region, however if I lower the arguments of the first pointresize any further, in order to intensify the blur, it seems like the picture seems to "leak" through effectively making the bluring less.
The "leaking" you are seeing comes from the chroma of the original clip. It shows up more when you make the first resize smaller, because that makes the final 'blocks' bigger and hence the result more uniform in luma. The mt_merge needs to be changed to mt_merge(..., luma=true) to mask out the original chroma inside the circle.

blazerqb11
9th December 2008, 19:29
Well, you've officially solved all my problems I can currently see. Thanks to everyone that helped me out, I can't stress enough how excellent the level of help I received was.

vcmohan
11th December 2008, 09:16
I authored a plugin quite sometime back, which I think can be used for this "censoring". Please see thread http://forum.doom9.org/showthread.php?t=143432