Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 24th June 2016, 17:48   #1  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
DitherPost Image Corruption

I have this script working fine.

Code:
ColorBarsHD(200, 200)
ResizeShader(600, 500, kernel="bicubic")


This also works fine, which means the output of the first resize gives a valid output
Code:
ColorBarsHD(200, 200)
ResizeShader(800, 600, kernel="bicubic", lsb_out=true)
ResizeShader(600, 500, kernel="bicubic", lsb_in=true)
This one, however, severely corrupts the image!
Code:
ColorBarsHD(200, 200)
ResizeShader(600, 500, kernel="bicubic", lsb_out=true)
DitherPost(mode=6)


The only thing I could think about is that values outside the 16-235 range could confuse DitherPost. I added a Clamp between 50 and 200 within the shader. Some colors were gone but the weird image corruption was still there!

This is the only thing I found to work
Code:
ColorBarsHD(200, 200)
ResizeShader(600, 500, kernel="bicubic", lsb_out=true)
Dither_convert_yuv_to_rgb (matrix="709", output="rgb48y", lsb_in=true)
r = SelectEvery (3, 0)
g = SelectEvery (3, 1)
b = SelectEvery (3, 2)
Dither_convert_rgb_to_yuv (r, g, b, matrix="709", lsb=true)
DitherPost(mode=6)
Any idea on what could be causing such image corruption?

Last edited by MysteryX; 27th June 2016 at 04:34.
MysteryX is offline   Reply With Quote
Old 27th June 2016, 02:30   #2  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
119 people looked at this already. Nobody has a clue on this one?
MysteryX is offline   Reply With Quote
Old 27th June 2016, 03:54   #3  |  Link
geometer
Registered User
 
Join Date: Dec 2015
Posts: 59
as it seems to me, that "corruption" is more like a moral judgement, first thing I would ask you - to define what you deem wrong in the result, using very specific and purely technical expressions.
second, I would anticipate the first posted picture to have 800*600px, and the second, 600*500px. the current difference is too small to be an issue to me, it just seems one has a tad brighter colors.
geometer is offline   Reply With Quote
Old 27th June 2016, 04:31   #4  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
I'll confess when I looked at the images my reaction was "what corruption?" but I refrained from asking in case doing so eventually made me look silly.

There's a tiny difference in colour (or probably more accurately, luminance or gamma), but isn't that somewhat normal when resizing? The scripts indicate different resizing while the screenshots are the same resolution and that may have been a typo but it was too confusing for my poor brain.
hello_hello is offline   Reply With Quote
Old 27th June 2016, 04:33   #5  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by geometer View Post
as it seems to me, that "corruption" is more like a moral judgement, first thing I would ask you - to define what you deem wrong in the result, using very specific and purely technical expressions.
Besides the slight color distortion which you see with DitherPost(mode=0), when using mode=6, the lower part has horizontal lines screwing up the lower blocks

Quote:
Originally Posted by geometer View Post
second, I would anticipate the first posted picture to have 800*600px, and the second, 600*500px
That a typo When I originally posted it, the internet went down and the whole post was lost. I retyped it quickly but that error leaked in. Fixed the scripts.

Last edited by MysteryX; 27th June 2016 at 04:36.
MysteryX is offline   Reply With Quote
Old 28th June 2016, 02:33   #6  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Curious. I tried magnifying the distortion to make it more visible. If I change brightness/constrast, or if I upscale the image in Photoshop, the distortion lines disappears. I can't make a more visible version of it.

It's most visible in the lower-right corner of the picture I posted.
MysteryX is offline   Reply With Quote
Old 28th June 2016, 03:22   #7  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Dither is doing exactly what it is designed to do.
Perhaps this will help - first image, cropped and enlarged 4x (click to view in a new tab)

Second image, cropped and enlarged 4x.


Can't see the difference? Click here.

EDIT I suspect you are seeing some interaction between the dither pattern and your screen.

Last edited by raffriff42; 16th March 2017 at 23:11. Reason: (fixed image links)
raffriff42 is offline   Reply With Quote
Old 28th June 2016, 05:57   #8  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Here's a way to see the difference. Looking at the raw Stack16 data before DitherPost.

Code:
// distortion
ColorBarsHD(200, 200)
ResizeShader(600, 500, kernel="bicubic", lsb_out=true)


Code:
// OK
ColorBarsHD(200, 200)
ResizeShader(600, 500, kernel="bicubic", lsb_out=true)
Dither_convert_yuv_to_rgb (matrix="709", output="rgb48y", lsb_in=true)
r = SelectEvery (3, 0)
g = SelectEvery (3, 1)
b = SelectEvery (3, 2)
Dither_convert_rgb_to_yuv (r, g, b, matrix="709", lsb=true)
MysteryX is offline   Reply With Quote
Old 29th June 2016, 05:23   #9  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by raffriff42 View Post
I suspect you are seeing some interaction between the dither pattern and your screen.
Whether that's the case or not, there shouldn't be any difference between the 2 Stack16 images posted above.

It may not be a big issue, but closing my eyes on that one can lead to other problems. I think that many C++ and especially ASM programmers around here are familiar with that truth.
MysteryX is offline   Reply With Quote
Old 29th June 2016, 05:26   #10  |  Link
geometer
Registered User
 
Join Date: Dec 2015
Posts: 59
What disturbs me most, is the color subsampling and the "Gibb" with it.
Frequency spectrum among the two is definitely different, the halos have different width and intensity.
The spectral transfer diagram is quite important to judge influence on noise.
E.g. after the dithering to do some filtering again is likely to have chaotic results on the appearance of the noise.

Last edited by geometer; 29th June 2016 at 05:32.
geometer is offline   Reply With Quote
Old 29th June 2016, 06:39   #11  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by MysteryX View Post
there shouldn't be any difference between the 2 Stack16 images posted above.
Really, why? In the second image you are converting YUV>>RGB>>YUV; how can that not make a difference? You know, a very small - even invisible - change in the DitherPost'ed image can change the LSB part of the stack16 image quite a bit.

The chroma is softer in the second image, as would be expected from the extra processing. A simple bicubic resize looks slightly better (IMHO), I'm sorry to say.
Code:
## "16bit bicubic"
ColorBarsHD(200, 200)
Dither_convert_8_to_16
Dither_resize16(600, 500, kernel="bicubic")
DitherPost
EDIT: Note, the images from postimg.org above seem to look worse re the problems geometer describes, than the images I get when running the scripts. I still think bicubic wins, even 8bit bicubic.

Last edited by raffriff42; 29th June 2016 at 06:49.
raffriff42 is offline   Reply With Quote
Old 29th June 2016, 07:22   #12  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I'm only using Bicubic in both cases.

Quote:
Originally Posted by raffriff42 View Post
Code:
ColorBarsHD(200, 200)
Dither_convert_8_to_16
Dither_resize16(600, 500, kernel="bicubic")
DitherPost
This case works, even with DitherPost(mode=6)

Why would this work while doing the Bicubic via ResizeShader result in output distortion? Is it only "random luck based on subtle difference"?

Quote:
Originally Posted by raffriff42 View Post
EDIT: Note, the images from postimg.org above seem to look worse re the problems geometer describes, than the images I get when running the scripts. I still think bicubic wins, even 8bit bicubic.
Copy/paste the image into Photoshop and you'll see the problem instantly gets worse (??)
MysteryX is offline   Reply With Quote
Old 29th June 2016, 07:44   #13  |  Link
geometer
Registered User
 
Join Date: Dec 2015
Posts: 59
depending on sender and receiver software, a copy-paste is a maze of data format transformations!
geometer is offline   Reply With Quote
Old 29th June 2016, 09:22   #14  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I'm testing it again with v1.5.1 (just released) and I'm not seeing the same distortion anymore. Not sure what changed.

Last edited by MysteryX; 29th June 2016 at 09:41.
MysteryX is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:21.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.