Log in

View Full Version : Remove every nth row of pixels from frames


SaurusX
27th June 2017, 16:47
I have an animated DVD that is an NTSC to PAL conversion. Whatever method they used to upscale the video to PAL resolution results in vertical blurring in every nth row of pixels (I haven't bothered to actually count rows yet). Is there a method or filter to remove every nth row of pixels thereby reducing the vertical resolution back down from 576 to 480?

I'm thinking that approach MAY fix this problem. Maybe. But in any case I haven't found a way to actually implement my idea.

sneaker_ger
27th June 2017, 19:33
It's tricky because of chroma sub-sampling. Probably best if you'd post a lossless sample and post it here.

johnmeyer
27th June 2017, 21:53
You might check out StainlessS' "RT_Stats" plugins. It contains lots of tools which make this sort of thing easier.

StainlessS
28th June 2017, 11:44
This seems to work OK (but not that elegant):-


src=Mpeg2source("z.d2v") # PAL 576
src=src.ConvertToYV24 # or RGB

# 576 - 480 = 96
# 576 / 96 = 6
# skip every 6th line

InLines = src.Height
OutLines = 480
InDrop = InLines - OutLines # 96
Every = InLines / InDrop # Integer only, 6

### CONFIG ###
Drop = 5 # 0 -> Every(6) - 1 : drop last of every 6 scanlines
##############

#RT_DebugF("InLines=%d",InLines)
#RT_DebugF("OutLines=%d",OutLines)
#RT_DebugF("InDrop=%d",InDrop)
#RT_DebugF("Every=%d",every)
#RT_DebugF("Drop=%d",Drop)

Assert(0 <= Drop < Every,String(Drop,"Bad Drop(%f) ")+String(Every,"for Every(%f)"))

o = 0 # will become clip

GSCript("""
Prv = -1
for(i=0,InDrop) { # Does 1 extra
n = i * Every + Drop # Scanline to drop
s = Prv + 1
e = Min(n - 1,src.Height-1)
if(s < src.Height && e>=0) {
# RT_DebugF("%d ] s=%d e=%d scanlines=%d : Crop(%d,%d,%d,%d)",i,s,e,e-s+1,0,s,0,e-s+1)
c = src.Crop(0,s,-0,e-s+1)
o = (o.isClip) ? o.StackVertical(c) : c
}
Prv = n # done to here
}
""")
#RT_DebugF("OutHeight=%d",o.Height)
o.convertToYV12 # or whatever
#return Last
Addborders(0,0,0,src.height-height)
Stackhorizontal(src.convertToYV12,last)
return Last



EDIT:
It's tricky because of chroma sub-sampling. Probably best if you'd post a lossless sample and post it here.
Dont know what if anything to do about chroma subsampling.
+1 on the post a sample thing.

SaurusX
28th June 2017, 13:56
Thanks for the assist! I haven't had the opportunity to test it yet, but I'll do that AND post a sample of the video later this evening.

Gavino
28th June 2017, 16:14
This seems to work OK (but not that elegant):-
I'm sure this could be done a lot more simply using just a single PointResize() (perhaps with a suitable vertical offset to make sure the right rows are dropped), but I don't have time to work out the details right now.

SaurusX
28th June 2017, 23:47
Here's that sample. It's got a few vertical scrolling scenes with some nice horizontal lines demonstrating the upscaling effect. I could be totally off base when it comes to removing scan lines solving the problem. Any help is, of course, appreciated.

Mega Link (https://mega.nz/#!h3pjBDaD!xCd3Xa319hLEfiMGgQsWAvoKdH2EmJORIJVNnol3oM4)

StainlessS
29th June 2017, 15:51
I'm sure this could be done a lot more simply using just a single PointResize() (perhaps with a suitable vertical offset to make sure the right rows are dropped), but I don't have time to work out the details right now.

Yep, was not sure how to do the offset thing, other than to crop/add back, figured that it would be easier with user adjusted offset, as it was done.

Made small mod to show original alongside modded.

I'll leave further investigation to others (I really have little interest in anime [and tend to call them cartoons]).