PDA

View Full Version : YUY2->YV12 Mjpeg and chroma noise


markanini
24th October 2009, 12:15
I'm dealing with noisy Mjpeg sources from a compact camera. I want to filter through MCTemporalDenoise and have some thoughts about the YUY2 to YV12 conversion required.
The converttoyv12 function uses point resampling which I imagine is bad for a noisy source. I've read about 'chromaresample' in v2.6 but I'm not sure if more sofistiacated resampling would do anything other than smooth chroma. Even better would be averaging but if my understanding of different chroma formats is correct this would not be reasonable with either losing vertical resolution or stiped chroma texture. Then also it depends on how McTemporalDenoise will like it.

Anyway I'm not very well versed in Avisynth yet so basically; Is there a better way than plain converttoyv12->mctemporaldenoise?

Gavino
24th October 2009, 15:28
The built-in YUY2->YV12 conversion uses bilinear resampling on the chroma.

But isn't MJPEG already YV12 anyway? Though I suppose what Avisynth gets as input depends on which decompressor you use.

scharfis_brain
24th October 2009, 18:08
MJPEG from digital still cameras usually is YUY2.

MJPEG can carry RGB, YUY2 and YV12.

markanini
24th October 2009, 22:28
The built-in YUY2->YV12 conversion uses bilinear resampling on the chroma.

But isn't MJPEG already YV12 anyway? Though I suppose what Avisynth gets as input depends on which decompressor you use.
Its definitely YUY2, gives me an idea though, converting to RGB32 fist by simple doubling of chroma plane horizontally, and then averaging the nice even numbered chroma down 1/4. As some might know averaging is good way to increase SNR so I'd love to see this as part of YUY2->YV12 on my noisy source.

thewebchat
25th October 2009, 00:35
Wait, where does RGB32 come into this? Also, in AviSynth 2.6 alpha, you can specify the resampler to use for YUV up/downsampling conversion, so you can do it losslessly.

scharfis_brain
25th October 2009, 01:03
There is a way to get rid of the stairstepping.

but it will introduce some loss in details


loadplugin("c:\x\nnedi2.dll")
directshowsource("airplane1.MOV")
converttoyuy2()
nnedi2(dh=true).separatefields().selectodd().nnedi2(dh=true)
converttoyv12()
turnleft().nnedi2(dh=true).turnright()
nnedi2(dh=true)
turnleft().nnedi2(dh=true).turnright()

markanini
25th October 2009, 04:46
Thanks for the script scharfis_brain definitely a big fan of NNEDI. I assmume directshowsource("x:\x\video.avi",pixel_type="yuy2")? It makes a nice upscaling filter. The file I'm working on right now is 640x480 so I'll keep it that way but some others are misstakenly set to 320x240 so I'll try the script on those later on. It crashes my system if i try to run mctemporaldenoise on the same script XD. What does it do different than nnedi2_rpow2? Sorry if it's a stupid question, as I mentioned earlier I'm not well versed in avisynth, but I'm willing to learn.

Otherwise I realize I'm letting this conversion go over my head. Essentially I'm halving vertical chroma resolution. The way I'd like to do it is having groups of two vertical chroma pixels averaged for slightly better SNR. I have no idea how to do this. Perhaps with chromaresample function and one of the resizers have such characteristics.

Trying to make it clearer with a simplified example:

IN(YUY2 chroma)
1x5x
3x7x
2x6x
4x8x

OUT(YV12 chroma)
2x6x
xxxx
3x7x
xxxx


Here's an good article about noise averaging: http://www.cambridgeincolour.com/techniques/image-averaging-noise.htm

Gavino
25th October 2009, 09:04
Essentially I'm halving vertical chroma resolution. The way I'd like to do it is having groups of two vertical chroma pixels averaged for slightly better SNR.
That's exactly what ConvertToYV12 (from YUY2) does - see here (http://avisynth.org/mediawiki/Sampling#YUY2_-.3E_YV12_progressive_conversion).
But I may have misunderstood what you want as I don't understand your example.

scharfis_brain
25th October 2009, 09:39
whoops, my reply above was not mentioned for this thread...

markanini
25th October 2009, 10:06
That's exactly what ConvertToYV12 (from YUY2) does - see here (http://avisynth.org/mediawiki/Sampling#YUY2_-.3E_YV12_progressive_conversion).
But I may have misunderstood what you want as I don't understand your example.
The last 15 minutes I've been reading some articles, or atleast tried there rather technical, about bilinear filtering and all seems to point that way.
Great guess I'm all set then! :thanks: