D90 Stair-Stepping Removal

cgipro, every time I tried to open the file, I always have this error:

Avisynth open failure:
crop: YV12 images can only be cropped by even numbers (bottom).
(c:\Documents and Settings\Administrator\Desktop\destop.avs, line 52)
 
cgipro, every time I tried to open the file, I always have this error:

Avisynth open failure:
crop: YV12 images can only be cropped by even numbers (bottom).
(c:\Documents and Settings\Administrator\Desktop\destop.avs, line 52)


I haven't encountered this myself. Are you working with the AVI file straight out of the camera? That's the only thing I tested, so if you are using a video file that has been processed by some other software, it may not work.
 
Ok, I just tried with the AVI file straight out of the camera and it worked, so the problem is from the encoded file from Premiere CS3... I will try different encoding solution... or process all the AVI before editing.

Thanks cgipro.
 
Hey CGIPro

Your script is very similar to what I put together, I too have a quad core with 8GB Ram and my script runs in real time when played back in Media Player Classic, but will render at about 18FPS when encoding to Lagarith. (I do use BilinearResize for my tests whereas you used Lanczos4Resize which usually involves some form of speed penalty).

I've looked at your script and there are similarities and differences in how we went about it.

Like you, I also used the whole cropping and vertical stacking.

Unlike you however I did a "layer" filtration step on the video using operation mode = "fast" which basically does an average blend of the two videos. So in order to get the in-between slices rows of pixels, I simply created two instances of the video, one with a 1 row pixel cropped off the bottom, and one where it is cropped from the top. This means that layering the two videos has a similar effect to taking those individual offest rows and blending them.

So rather than doing a layer for each inter-slice row, I just made the video instance and cropped rows of 1 pixel heights from the blended instance at the appropriate places.

I'm also curious as to how your video is able to render as the version of AVISynth I am using forces me to convert the video to RGB before being able to do any cropping/resizing where they are not the right multiples.

Going back to the resizing methods, I am reluctant to use Lanczos4Resize as it does introduce ringing and given that the source is not super clean, I'd rather not introduce more artefacts. In the later versions of AVISynth they have added BlackmanResize which is supposed to be an improved Lanczos4Resize without the ringing. If speed is not an issue though we should be using Spline resize :)

I'm still experimenting with denoising algos at the moment but with work getting in the way, I haven't had much time to experiment.

Ideally with the D90 video, we'd want to vertically stack all the slices, resize it using a non ringing filter to a larger size, perform the denoising on this larger size using less destructive paramters, and then bring the video back down to native res. This is similar to what I used to do when upscaling DVDs. The upsizing and resizing steps should be all the sharpening we need.

The other method to look into for sharpening D90 content (I shoot D90 video with sharpening turned off to improve the compressibility of the clips) are those selective masking type sharpening scripts e.g. SeeSaw and LimitedSharpen and LimitedSharpenFaster in all their various incarnations.

From what I am reading, SeeSaw should also help with denoising to a very small extent as well. I guess it might be the one stop solution if the video is relatively clean.

Hopefully I will have more time to play with this soon, however I do hope the above will assist you with coming up with a better script that is also faster.

I'm sure with the collective brain power of all those on this board, we can come up with a one size fits all solution that is easy to use.

My settings for D90 picture control are:
Neutral with 0 sharpening, -2 contrast and the rest at 0. Saturation can be changed to suit tastes, however if going for a more film type look, I think dropping it down to -1 would help a bit. I'll be experimenting with other settings later (e.g. Portrait as base for when shooting people, and landscape when shooting er... landscape :))
 
I just had an epiphany :)

I now realise why your script works without having to convert to RGB!

Being that the first line is a DirectShowSource call to the video file. It will use whatever decoder is installed on the system to render the video. Since I use FFDShow atm (will try out a proper MJPEG decoder) and have forced my FFDShow to output YV12, AVISynth will see my video as YV12.

So to anyone who is having trouble with CGIPro's script, there are two ways around this.

One is to ensure that the decoder you are using is outputting RGB. Second method if you are not comfortable playing around with your codecs settings is to use the AVISynth "ConvertToRGB" command.

You could use it like this:

file = DirectShowSource("C:\movie.avi")
source = ConvertToRGB(file)

Hope this helps.

Cheers...
 
BTW, CGIPro

Thanks for mentioning the changes in the "magic numbers".

I noticed some glitching on particular lines in my video as well, which was why I was reluctant to post my AVISynth script up earlier until I had some time to do a more conclusive determination of the slice heights.

I'll try your numbers when I get a chance and if eyeballing the results shows no noticeable glitching, I can leave it at that, otherwise I'll have to record some video specifically to determine where the slices are (just need to shoot a high contrast solid diagonal line).
 
Thanks hdkhang, you've provided a lot of useful information so I'll do some more testing to see what I can come up with!
 
I experimented with the layer method, but wasn't able to get any speed improvement. Here's a small bit of the script code I'm using:

Code:
video = "d:\movie.avi"

source = DirectShowSource(video)
blended = Layer(source, source, x=0, y=-1, op="fast")

slice0 = Crop(source, 0, 0, 1280, 7)
blend0 = Crop(blended, 0, 6, 1280, 1)
slice1 = Crop(source, 0, 7, 1280, 9)
blend1 = Crop(blended, 0, 15, 1280, 1)
slice2 = Crop(source, 0, 16, 1280, 9)
blend2 = Crop(blended, 0, 24, 1280, 1)
...
...
## Continue through all slices

StackVertical(slice0,blend0,slice1,blend1,...)

BilinearResize(1280,720)

The only thing I did discover is that you don't need to do the cropping before layering, since the Layer function allows you to use an offset.

If anyone else has ideas for improvement, please post!
 
Hi CGIPro. Nice find on the Layer command having an offset. :thumbup:

I've tried your modified magic numbers and they appear to do the trick (not to mention they look more symmetrical).

I've updated my script to use your numbers (excel comes in handy ehehe) and replaced the denoise3d filter with an undot filter so as to leave the major noise removal to a more capable filter once I've had time to experiment with a few (NeatVideo is available for VirtualDub but not going to test non free solutions for now, if others have the filter then hopefully they can assist here).

Not sure why there exists a speed difference, maybe it has to do with something else in the chain. In any case, try my variant and we'll know if there is any speed penalty. (Just remove undot and the preceding ConvertToYV12 in the second last line if you want a better comparative point for speed).

On my Q6600 (no overclocking) I get
18FPS with BilinearResize
16FPS with Spline16Resize

UnDot usually drops the rendering speed by a further 1FPS.

Code:
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\UnDot.dll")
source = DirectShowSource("E:\Transfer\DSC_0004.avi")
rgbsource = ConvertToRGB(source)
blendsource = Layer(rgbsource, rgbsource, x=0, y=-1, op="fast")

s01 = Crop(rgbsource, 0, 0, -0, -713)
s02 = Crop(rgbsource, 0, 7, -0, -704)
s03 = Crop(rgbsource, 0, 16, -0, -695)
s04 = Crop(rgbsource, 0, 25, -0, -687)
s05 = Crop(rgbsource, 0, 33, -0, -678)
s06 = Crop(rgbsource, 0, 42, -0, -669)
s07 = Crop(rgbsource, 0, 51, -0, -660)
s08 = Crop(rgbsource, 0, 60, -0, -651)
s09 = Crop(rgbsource, 0, 69, -0, -642)
s10 = Crop(rgbsource, 0, 78, -0, -634)
s11 = Crop(rgbsource, 0, 86, -0, -625)
s12 = Crop(rgbsource, 0, 95, -0, -616)
s13 = Crop(rgbsource, 0, 104, -0, -607)
s14 = Crop(rgbsource, 0, 113, -0, -598)
s15 = Crop(rgbsource, 0, 122, -0, -590)
s16 = Crop(rgbsource, 0, 130, -0, -581)
s17 = Crop(rgbsource, 0, 139, -0, -572)
s18 = Crop(rgbsource, 0, 148, -0, -563)
s19 = Crop(rgbsource, 0, 157, -0, -554)
s20 = Crop(rgbsource, 0, 166, -0, -545)
s21 = Crop(rgbsource, 0, 175, -0, -537)
s22 = Crop(rgbsource, 0, 183, -0, -528)
s23 = Crop(rgbsource, 0, 192, -0, -519)
s24 = Crop(rgbsource, 0, 201, -0, -510)
s25 = Crop(rgbsource, 0, 210, -0, -501)
s26 = Crop(rgbsource, 0, 219, -0, -492)
s27 = Crop(rgbsource, 0, 228, -0, -484)
s28 = Crop(rgbsource, 0, 236, -0, -475)
s29 = Crop(rgbsource, 0, 245, -0, -466)
s30 = Crop(rgbsource, 0, 254, -0, -457)
s31 = Crop(rgbsource, 0, 263, -0, -448)
s32 = Crop(rgbsource, 0, 272, -0, -439)
s33 = Crop(rgbsource, 0, 281, -0, -431)
s34 = Crop(rgbsource, 0, 289, -0, -422)
s35 = Crop(rgbsource, 0, 298, -0, -413)
s36 = Crop(rgbsource, 0, 307, -0, -404)
s37 = Crop(rgbsource, 0, 316, -0, -395)
s38 = Crop(rgbsource, 0, 325, -0, -386)
s39 = Crop(rgbsource, 0, 334, -0, -378)
s40 = Crop(rgbsource, 0, 342, -0, -369)
s41 = Crop(rgbsource, 0, 351, -0, -360)
s42 = Crop(rgbsource, 0, 360, -0, -351)
s43 = Crop(rgbsource, 0, 369, -0, -342)
s44 = Crop(rgbsource, 0, 378, -0, -334)
s45 = Crop(rgbsource, 0, 386, -0, -325)
s46 = Crop(rgbsource, 0, 395, -0, -316)
s47 = Crop(rgbsource, 0, 404, -0, -307)
s48 = Crop(rgbsource, 0, 413, -0, -298)
s49 = Crop(rgbsource, 0, 422, -0, -289)
s50 = Crop(rgbsource, 0, 431, -0, -281)
s51 = Crop(rgbsource, 0, 439, -0, -272)
s52 = Crop(rgbsource, 0, 448, -0, -263)
s53 = Crop(rgbsource, 0, 457, -0, -254)
s54 = Crop(rgbsource, 0, 466, -0, -245)
s55 = Crop(rgbsource, 0, 475, -0, -236)
s56 = Crop(rgbsource, 0, 484, -0, -228)
s57 = Crop(rgbsource, 0, 492, -0, -219)
s58 = Crop(rgbsource, 0, 501, -0, -210)
s59 = Crop(rgbsource, 0, 510, -0, -201)
s60 = Crop(rgbsource, 0, 519, -0, -192)
s61 = Crop(rgbsource, 0, 528, -0, -183)
s62 = Crop(rgbsource, 0, 537, -0, -175)
s63 = Crop(rgbsource, 0, 545, -0, -166)
s64 = Crop(rgbsource, 0, 554, -0, -157)
s65 = Crop(rgbsource, 0, 563, -0, -148)
s66 = Crop(rgbsource, 0, 572, -0, -139)
s67 = Crop(rgbsource, 0, 581, -0, -130)
s68 = Crop(rgbsource, 0, 590, -0, -122)
s69 = Crop(rgbsource, 0, 598, -0, -113)
s70 = Crop(rgbsource, 0, 607, -0, -104)
s71 = Crop(rgbsource, 0, 616, -0, -95)
s72 = Crop(rgbsource, 0, 625, -0, -86)
s73 = Crop(rgbsource, 0, 634, -0, -78)
s74 = Crop(rgbsource, 0, 642, -0, -69)
s75 = Crop(rgbsource, 0, 651, -0, -60)
s76 = Crop(rgbsource, 0, 660, -0, -51)
s77 = Crop(rgbsource, 0, 669, -0, -42)
s78 = Crop(rgbsource, 0, 678, -0, -33)
s79 = Crop(rgbsource, 0, 687, -0, -25)
s80 = Crop(rgbsource, 0, 695, -0, -16)
s81 = Crop(rgbsource, 0, 704, -0, -7)
s82 = Crop(rgbsource, 0, 713, -0, -0)
b01 = Crop(blendsource, 0, 6, -0, -713)
b02 = Crop(blendsource, 0, 15, -0, -704)
b03 = Crop(blendsource, 0, 24, -0, -695)
b04 = Crop(blendsource, 0, 32, -0, -687)
b05 = Crop(blendsource, 0, 41, -0, -678)
b06 = Crop(blendsource, 0, 50, -0, -669)
b07 = Crop(blendsource, 0, 59, -0, -660)
b08 = Crop(blendsource, 0, 68, -0, -651)
b09 = Crop(blendsource, 0, 77, -0, -642)
b10 = Crop(blendsource, 0, 85, -0, -634)
b11 = Crop(blendsource, 0, 94, -0, -625)
b12 = Crop(blendsource, 0, 103, -0, -616)
b13 = Crop(blendsource, 0, 112, -0, -607)
b14 = Crop(blendsource, 0, 121, -0, -598)
b15 = Crop(blendsource, 0, 129, -0, -590)
b16 = Crop(blendsource, 0, 138, -0, -581)
b17 = Crop(blendsource, 0, 147, -0, -572)
b18 = Crop(blendsource, 0, 156, -0, -563)
b19 = Crop(blendsource, 0, 165, -0, -554)
b20 = Crop(blendsource, 0, 174, -0, -545)
b21 = Crop(blendsource, 0, 182, -0, -537)
b22 = Crop(blendsource, 0, 191, -0, -528)
b23 = Crop(blendsource, 0, 200, -0, -519)
b24 = Crop(blendsource, 0, 209, -0, -510)
b25 = Crop(blendsource, 0, 218, -0, -501)
b26 = Crop(blendsource, 0, 227, -0, -492)
b27 = Crop(blendsource, 0, 235, -0, -484)
b28 = Crop(blendsource, 0, 244, -0, -475)
b29 = Crop(blendsource, 0, 253, -0, -466)
b30 = Crop(blendsource, 0, 262, -0, -457)
b31 = Crop(blendsource, 0, 271, -0, -448)
b32 = Crop(blendsource, 0, 280, -0, -439)
b33 = Crop(blendsource, 0, 288, -0, -431)
b34 = Crop(blendsource, 0, 297, -0, -422)
b35 = Crop(blendsource, 0, 306, -0, -413)
b36 = Crop(blendsource, 0, 315, -0, -404)
b37 = Crop(blendsource, 0, 324, -0, -395)
b38 = Crop(blendsource, 0, 333, -0, -386)
b39 = Crop(blendsource, 0, 341, -0, -378)
b40 = Crop(blendsource, 0, 350, -0, -369)
b41 = Crop(blendsource, 0, 359, -0, -360)
b42 = Crop(blendsource, 0, 368, -0, -351)
b43 = Crop(blendsource, 0, 377, -0, -342)
b44 = Crop(blendsource, 0, 385, -0, -334)
b45 = Crop(blendsource, 0, 394, -0, -325)
b46 = Crop(blendsource, 0, 403, -0, -316)
b47 = Crop(blendsource, 0, 412, -0, -307)
b48 = Crop(blendsource, 0, 421, -0, -298)
b49 = Crop(blendsource, 0, 430, -0, -289)
b50 = Crop(blendsource, 0, 438, -0, -281)
b51 = Crop(blendsource, 0, 447, -0, -272)
b52 = Crop(blendsource, 0, 456, -0, -263)
b53 = Crop(blendsource, 0, 465, -0, -254)
b54 = Crop(blendsource, 0, 474, -0, -245)
b55 = Crop(blendsource, 0, 483, -0, -236)
b56 = Crop(blendsource, 0, 491, -0, -228)
b57 = Crop(blendsource, 0, 500, -0, -219)
b58 = Crop(blendsource, 0, 509, -0, -210)
b59 = Crop(blendsource, 0, 518, -0, -201)
b60 = Crop(blendsource, 0, 527, -0, -192)
b61 = Crop(blendsource, 0, 536, -0, -183)
b62 = Crop(blendsource, 0, 544, -0, -175)
b63 = Crop(blendsource, 0, 553, -0, -166)
b64 = Crop(blendsource, 0, 562, -0, -157)
b65 = Crop(blendsource, 0, 571, -0, -148)
b66 = Crop(blendsource, 0, 580, -0, -139)
b67 = Crop(blendsource, 0, 589, -0, -130)
b68 = Crop(blendsource, 0, 597, -0, -122)
b69 = Crop(blendsource, 0, 606, -0, -113)
b70 = Crop(blendsource, 0, 615, -0, -104)
b71 = Crop(blendsource, 0, 624, -0, -95)
b72 = Crop(blendsource, 0, 633, -0, -86)
b73 = Crop(blendsource, 0, 641, -0, -78)
b74 = Crop(blendsource, 0, 650, -0, -69)
b75 = Crop(blendsource, 0, 659, -0, -60)
b76 = Crop(blendsource, 0, 668, -0, -51)
b77 = Crop(blendsource, 0, 677, -0, -42)
b78 = Crop(blendsource, 0, 686, -0, -33)
b79 = Crop(blendsource, 0, 694, -0, -25)
b80 = Crop(blendsource, 0, 703, -0, -16)
b81 = Crop(blendsource, 0, 712, -0, -7)

stack1 = StackVertical(s01,b01,s02,b02,s03,b03,s04,b04,s05,b05,s06,b06,s07,b07,s08,b08,s09,b09)
stack2 = StackVertical(s10,b10,s11,b11,s12,b12,s13,b13,s14,b14,s15,b15,s16,b16,s17,b17,s18,b18)
stack3 = StackVertical(s19,b19,s20,b20,s21,b21,s22,b22,s23,b23,s24,b24,s25,b25,s26,b26,s27,b27)
stack4 = StackVertical(s28,b28,s29,b29,s30,b30,s31,b31,s32,b32,s33,b33,s34,b34,s35,b35,s36,b36)
stack5 = StackVertical(s37,b37,s38,b38,s39,b39,s40,b40,s41,b41,s42,b42,s43,b43,s44,b44,s45,b45)
stack6 = StackVertical(s46,b46,s47,b47,s48,b48,s49,b49,s50,b50,s51,b51,s52,b52,s53,b53,s54,b54)
stack7 = StackVertical(s55,b55,s56,b56,s57,b57,s58,b58,s59,b59,s60,b60,s61,b61,s62,b62,s63,b63)
stack8 = StackVertical(s64,b64,s65,b65,s66,b66,s67,b67,s68,b68,s69,b69,s70,b70,s71,b71,s72,b72)
stack9 = StackVertical(s73,b73,s74,b74,s75,b75,s76,b76,s77,b77,s78,b78,s79,b79,s80,b80,s81,b81,s82)

stackedsource = StackVertical(stack1, stack2, stack3, stack4, stack5, stack6, stack7, stack8, stack9)

finalvideo = Spline16Resize(stackedsource, 1280, 720).ConvertToYV12().UnDot()

return finalvideo
Cheers...
 
Great stuff hdkhang, this is a big speed improvement for me. I'm now able to render at ~18 fps (Q9450 with Spline16Resize and no UnDot) so the order of operations must have an affect on the processing speed. It's also possible that AviSynth is better optimized to handle the negative crop offsets that your script uses.

Anyway, it works great and the output looks very nice. I'll post your optimized version on the page I setup. Thanks again!!
 
Where can I find the needed codec support for AE? When I try to import raw .AVI's from the camera, After Effects 7 just tells me "After Effects error: no such AVI compressor. (-2147205007)
 
Where can I find the needed codec support for AE? When I try to import raw .AVI's from the camera, After Effects 7 just tells me "After Effects error: no such AVI compressor. (-2147205007)

Too much information !

Seems you can (or cannot) import non-D90 AVIs, I think the problem might be to do with your current version of OS X / windows / Vista.
 
I can import basically any other type of .AVI into AE7, maybe it's a codec issue?

On the other hand, will your fix work if I just encode the footage to a different codec, or does it have to be in the standard MJPEG .AVI?
 
Last edited:
I can import basically any other type of .AVI into AE7, maybe it's a codec issue?

Yes, maybe ! The point I was attempting to make was that if you really want someone to help work your problem out for you, maybe you could see your way to providing some basic information ? So far we know you cannot import D90 files to AE - but you can import other non-D90 AVIs.

Now I could waste my time by suggesting that you check the version of OS X you are running has the latest XXXXXX - or that your copy of Vista has the XXXXX extension - or that you have updated the XXXXX on Windows - or that you are running FLIP4MAC - or that your copy of AE has the XXXXX plug-in . . . . but I would be wasting both your time and mine as it would be nothing more than guess work.

. . . so instead I am going to write two plays, one on how not to consult a doctor and one how you should consult a doctor !! :D


First how not to consult a doctor.


Patient: I don't feel well.

Doctor: What is the problem ?

Patient: It's hurts.

Doctor: What hurts ?

Patient: My body.

Doctor: Which part ?

Patient: The upper part.

Doctor: Your arms ?

Patient: No.

Doctor: Your chest ?

Patient: No.

Doctor: Your head ?

Patient: Yes ! my head hurts.

Doctor: Where specificallty on your head.

Patient: The upper part.

Doctor: . . . . oh, for f*&%$s sake, can you be specific.

Patient: The top of my head.

Doctor: Have you recently had an acciedent ?

Patient: Yes.

Doctor: Can you tell me what happened ?

Pateint: Yes.

Doctor: Go on then . . . . . . .


Etc . . . . .



Secondly how you should consult a doctor.


Patient: A flower pot fell on my head about 3 hours ago, I thought it would be ok by now, but it really hurts and I feel a little unwell, perhaps I have concussed myself ?

Doctor: Right, let's check you out . . . .


;P :D :D


So . . . . seems we appear to have adopted the 'how not to consult a doctor' route, let's get on with the painful process of extracting information. . . ;P

What operating system are you currently using ?
 
What more information was I expected to provide? I noted the version of After Effects I was on, as well as the error occurring, in detail. We already know the camera I am using as that was stated as well in the description which also leads to one having the codec in use as in this case, it is not variable.

Your description of the scenario would have been better fit if I initialized the post saying: "something is wrong."

I guess the only thing left to add would be the operating system and it's XP.
 
Here is my first attempt using the stair-stepping removal method created by Lee but based on Hasu technique in AE.


http://vimeo.com/2136552


ORIGINAL
3011346009_0f69ca2a5f.jpg


DISPLACEMENT MAP FILTER
3011345957_a87e0c76f1.jpg

 
Back
Top