View Full Version : How can I shift a picture and blend it with the original ?
SuperLumberjack
15th July 2019, 17:41
Note :
I began to ask my questions on another thread, but it became a bit off-topic :p So I asked a moderator (thanks tebasuna51) to move the related posts on a new thread. It's why it begins (and continues...?) so strangly ! :D
Hello,
I don't know if I'm on the good topic, but I'm exactly looking for a kind of blur that could allow me to shift a certain number of pixels vertically and horizontally and blend them.
I suppose that it's working like that.
Here is the original picture :
https://i.lensdump.com/i/Wb6cDo.md.png (https://lensdump.com/i/Wb6cDo)
Here is the same image with the blur :
https://i.lensdump.com/i/Wb6bW9.md.png (https://lensdump.com/i/Wb6bW9)
As we can see the entire picture moved from 1 pixel in 3 to the right and to the bottom.
https://i.lensdump.com/i/Wb6w92.md.png (https://lensdump.com/i/Wb6w92)
Do you think I can do the same thing with your blur filter ?
If it's not the case, with what kind of blur filter can I do the same thing please ?
Thanks for your help ! ;)
It's my only question !
SuperLumberjack
16th July 2019, 17:42
Somebody has an idea how to do that please ?
I think it's a kind of blur, or it's a bit like we double the image, move the second image and then blend it with the 1rst.
I don't know. I'm not the pro here ! :p
But thank you for helping me ! ;)
[I precise that I didn't create a new topic just for this question, to not uselessly pollute the forums. I thought there was a link with this subject. I hope that it's the case and that I'm not off-topic. I don't know. As I said, you are the pros, not me ! ^_^
It's just one question !]
StainlessS
16th July 2019, 18:22
Think this is about right for the shift [can then use Merge() or Overlay(), or Layer() or whatever (to blend, rather than blur)].
# Stack Overhead Subtitle Text, with optional FrameNumber shown.
Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){
c.BlankClip(height=20,Color=Default(Col,0))
(Default(ShowFrameNo,False))?ScriptClip("""Subtitle(String(current_frame,"%.f] """+Tit+""""))"""):Trim(0,-1).Subtitle(Tit)
Return StackVertical(c).AudioDubEx(c)
}
A=Imagesource(".\1.png",end=0).convertToRGB24
#B=Imagesource(".\2.png",end=0).convertToRGB24
#subtract(A,B)
# shift Left and Up 10 pixels
x = -10.0 # -ve, shift Left, +ve Shift Right
y = -10.0 # -ve, shift Up, +ve Shift Down
PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
C=A.BlankClip(Height=20,Color=$FFFF00) # Seperator bar
StackVertical(A.TSub("ORG"),C,Last.TSub("Shifted " + (x<0.0?"Left":"Right") + ":" + (y<0.0?"Up ":"Down ") + String(abs(x),"%.2f")+":"+String(abs(y),"%.2f")))
EDITED: changed x/y directions.
https://i.postimg.cc/rsFsGkMH/1-00.png (https://postimages.org/)
EDIT: Or I guess that you could just use eg
A=Imagesource(".\1.png",end=0).convertToRGB24
#B=Imagesource(".\2.png",end=0).convertToRGB24
#subtract(A,B)
# shift Left and Up 10 pixels
x = -10 # -ve, shift Left, +ve Shift Right
y = -10 # -ve, shift Up, +ve Shift Down
A.Layer(A,x=x,y=y,Opacity=0.5)
EDITED: changed x/y directions.
or similar. [Single clip, shifted using x,y, and blended 50:50.]
EDIT: Watch out, for above code block x and y have to be Type Int, so I changed types of x and y [I thought they were actually Type Float args, but not so].
SuperLumberjack
16th July 2019, 19:33
Thanks StainlessS ! ;)
Yes, it's something like that to move the picture :)
But I expected a script more simple to be honest ! :p
It seems a bit complicated :(
And I need to get the exact same result than this :
https://i.lensdump.com/i/Wb6bW9.md.png (https://lensdump.com/i/Wb6bW9)
I precise that I took the capture from the top left corner of the original image and then zoomed to 400%.
Thank you very much for your help ! ;)
And sorry if I was off-topic ! :o
StainlessS
16th July 2019, 21:40
But I expected a script more simple to be honest
Most of that was just to show and title the input and output, if you dont wannit, then dont use it, ie remove the excess, something like this.
A=Imagesource(".\1.png",end=0).convertToRGB24
# shift Left and Up 10 pixels
x = -10.0 # -ve, shift Left, +ve Shift Right
y = -10.0 # -ve, shift Up, +ve Shift Down
OP=0.5 # blend ratio
PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(Last,Opacity=OP)
Or for int shift only use this
A=Imagesource(".\1.png",end=0).convertToRGB24
# shift Left and Up 10 pixels
x = -10 # -ve, shift Left, +ve Shift Right
y = -10 # -ve, shift Up, +ve Shift Down
OP=0.5
A.Layer(A,x=x,y=y,Opacity=OP) # Oops, Opacity arg exists only for recent Avs+
It dont seem that complicookered, set whatever X,Y you wish, I just use big numbers because you images were big..
EDIT:
A=Imagesource(".\1.png",end=0).convertToYV24 # Or to RGB24
Z=Imagesource(".\2.png",end=0).convertToYV24
x = 2.0 # -ve, shift Left, +ve Shift Right
y = 2.0 # -ve, shift Up, +ve Shift Down
OP= 0.5 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
Subtract(Last,Z) # difference to the required frame, Mess with X and Y until this is pure grayscale, then comment out this line
Above, might be of use to find appropriate X, and Y, but I dont think that you will be successful,
what makes you think that whatever produces the required output did it by shifting and blending (well you say bluring) pixels.
SuperLumberjack
16th July 2019, 23:20
Thank you very much ! :thanks:
I said it's complicated, because for me it's really complicated :p I'm not the boss with the AviSynth scripts.
I usually do very simple things ! :o
I need to study all of this to understand how to use it :D
I understand the principle, but I don't always know how to replace the values in the model, because I don't know all these functions and how they work. I will try ! ;)
Thanks ! :)
SuperLumberjack
16th July 2019, 23:55
I tested and it works ! Amazing ! Bravo ! :p
I must do some adjustments, but it's not far ! :)
Just a question, if I want to resize the picture at the beginning, where and how need I to insert the function ?
I know... I'm a real noob compared to you ! :D
But :thanks:
I appreciate your help and your skills are really impressive ! ;)
StainlessS
17th July 2019, 01:11
where and how need I to insert the function ?
A=Imagesource(".\1.png",end=0).convertToYV24 # Or to RGB24
#Z=Imagesource(".\2.png",end=0).convertToYV24
A=A.Spline36Resize(...) # whatever
#Z=Z.Spline36Resize(...) # whatever
x = 2.0 # -ve, shift Left, +ve Shift Right
y = 2.0 # -ve, shift Up, +ve Shift Down
OP= 0.5 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
#Subtract(Last,Z) # difference to the required frame, Mess with X and Y until this is pure grayscale, then comment out this line
return Last
SuperLumberjack
17th July 2019, 10:18
I tried something like that, but I just put this :p :
A=Spline36Resize(...)
Z=Spline36Resize(...)
And it didn't work in fact :D
Instead of this
A=A.Spline36Resize(...)
Z=Z.Spline36Resize(...)
But why did you comment the 2nd line ?
By the way, do you think I have to create a new topic ? I'm a bit embarrassed to use this topic which wasn't mine :(
But I thought there was a report with the subject.
Edit 1:
I tried with a easier picture, because we only need to shift from 1 pixel.
Here is the original picture :
https://i.lensdump.com/i/WwcIf9.th.png (https://lensdump.com/i/WwcIf9)
Here is the same but upscaled 16X with PointResize :
https://i.lensdump.com/i/Wwcg02.md.png (https://lensdump.com/i/Wwcg02)
The goal to achieve :
https://i.lensdump.com/i/Wwcrqv.md.png (https://lensdump.com/i/Wwcrqv)
I'm happy to say that I succeeded at least for the horizontal shift ;)
https://i.lensdump.com/i/WwctYC.md.png (https://lensdump.com/i/WwctYC)
x = 1.0 # -ve, shift Left, +ve Shift Right
y = 0.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
I checked the values in MS Paint and it's good ! But verticaly, I tried several values in the script and it's not that yet.
But thank you so much ! :) I didn't think that I would go so far.
Edit 2 :
The only problem is with some pixels which are the result of the horizontal blendind and the vertical blending and in addition are blended together. I don't know if I'm clear.
https://i.lensdump.com/i/WwXkA1.md.png (https://lensdump.com/i/WwXkA1)
x = 1.0 # -ve, shift Left, +ve Shift Right
y = 1.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
StainlessS
17th July 2019, 14:40
A=Spline36Resize(...)
#Z=Spline36Resize(...)
I dont know what resizer you want to use, nor the size, I presume that you know that ['...', meant that there is something missing].
I commented out the 2nd line because it was not used (assuming that you had found the required shifts).
You could ask a moderator to extract from your first post to a new thread, tell him from which post number, and maybe new thread title.
SuperLumberjack
17th July 2019, 15:07
OK. Thanks for you help ! ;)
It was very useful !
Yes, I think I will ask a moderator to create a new thread later and to copy these posts. It's better for the person who created this topic I suppose ! :p
Edit : Done ! Thanks to tebasuna51 !
SuperLumberjack
19th July 2019, 16:46
Hello,
Could somebody help me to get this please ? :o
https://i.lensdump.com/i/Wwcrqv.md.png (https://lensdump.com/i/Wwcrqv)
As you can see, I thought that I was close with this, but there are some differences :( :
https://i.lensdump.com/i/WwXkA1.md.png (https://lensdump.com/i/WwXkA1)
A=Imagesource(".\picture.png",end=0).convertToRGB24 # Or to RGB24
x = 1.0 # -ve, shift Left, +ve Shift Right
y = 1.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
Edit : Ouch... in fact, I didn't see, but there are lots of all differences :D
Horizontally it's good I think, but not vertically. I think that another technic is used for the image vertically.
Here is the original picture :
https://i.lensdump.com/i/WwcIf9.th.png (https://lensdump.com/i/WwcIf9)
I only enlarged the image 16X at the end.
Thanks for your help ! :)
SuperLumberjack
19th July 2019, 17:55
I dit it ! :p
The problem is if I do directly that :
A=Imagesource(".\picture.png",end=0).convertToRGB24 # Or to RGB24
x = 1.0 # -ve, shift Left, +ve Shift Right
y = 1.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
I get this image with the wrong result :
https://i.lensdump.com/i/WwXkA1.md.png (https://lensdump.com/i/WwXkA1)
So I dit this in 2 times :
First, I blended horizontally and get this low resolution picture :
https://i.lensdump.com/i/WxGK2k.png (https://lensdump.com/i/WxGK2k)
A=Imagesource(".\source picture.png",end=0).convertToRGB24 # Or to RGB24
x = 1.0 # -ve, shift Left, +ve Shift Right
y = 0.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
If you want to see better, here is the same image enlarged 16X :
https://i.lensdump.com/i/WwctYC.md.png (https://lensdump.com/i/WwctYC)
I remind you that this is my source image :
https://i.lensdump.com/i/WwcIf9.png (https://lensdump.com/i/WwcIf9)
And to see better the source image :
https://i.lensdump.com/i/Wwcg02.md.png (https://lensdump.com/i/Wwcg02)
So, after I did the same thing, but I blended vertically the picture that was recently blended horizontally :
A=Imagesource(".\picture blended horizontally.png",end=0).convertToRGB24 # Or to RGB24
x = 0.0 # -ve, shift Left, +ve Shift Right
y = 1.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
And I got the good result :) :
https://i.lensdump.com/i/WxGpCx.md.png (https://lensdump.com/i/WxGpCx)
The only problem is : how can I achieve this in only 1 step, in 1 script ? :confused:
Thanks for your help ! :thanks:
StainlessS
19th July 2019, 18:20
A=Imagesource(".\source picture.png",end=0).convertToRGB24 # Or to RGB24
x = 1.0 # -ve, shift Left, +ve Shift Right
y = 0.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
A=Last # Make A as above
x = 0.0 # -ve, shift Left, +ve Shift Right
y = 1.0 # -ve, shift Up, +ve Shift Down
OP= 0.25 # blend ratio
B=PointResize(A,A.Width,A.Height,-x,-y,A.Width,A.Height)
A.Overlay(B,Opacity=OP) # Result
You really gorra learn at least a little bit of scripting. :)
SuperLumberjack
19th July 2019, 19:44
Yes, that's true ! But there is so much to learn, in so many different areas... :o
I am rather self-taught, but I must admit that I would learn the subtleties of the AviSynth scripts faster with the help of a professor ! :p
You are a good professor ! :D I learned lot of things with your help !
Thank you so much StainlessS ! :thanks:
You are the boss ! ;)
SuperLumberjack
15th August 2019, 17:31
Hello,
Just a question a bit off-topic : is there a way to delete repeated frames in a video please ? :confused:
:thanks:
StainlessS
16th August 2019, 07:16
Search "DeDup", or "Duplicates".
EDIT: http://avisynth.nl/index.php/External_filters#Duplicate_Frame_Detectors
SuperLumberjack
16th August 2019, 11:35
Thank you StainlessS ! :)
I already tested ExactDedup (becaus I need to use RGB24), but it didn't work :(
I got this error :
Avisynth open failure:
Script error: ExactDedup does not have a named argument "_keeplastframe"
So I tried to delete the "_" before just to see and I got this :
Avisynth read error:
ExactDedup: Trying to compute frames out of order. Did you try to seek during processing?
StainlessS
16th August 2019, 12:18
Yeh, on Wiki also (and in original source readme too):- http://avisynth.nl/index.php/ExactDedup
ExactDedup (clip, bool "firstpass", string "dupinfo", string "times", int "maxdupcount", bool "_keeplastframe", bool "show")
Although correct a little later on in same Readme.txt
- keeplastframe: Default false. Keeps the last frame of a run of duplicates.
If a run of duplicates is larger than maxdupcount, this
keeps only the last frame of the entire run, not of the
individual maxdupcount-size blocks
The Linear Access requirement is carried over from the original source, I only made a few small changes to fix one or two problems.
If your script is non linear (and it must be), then suggest that you temp save as AVI and process on that, however, I'm gonna guess that your
clip does not have 100.0% exact duplicates in it, and so will probably have no effect whatsoever on your source.
(Word 'Exact' in filter name means strictly EXACT duplicates, a single pixel differing by only 1 will be considered, NOT an EXACT dupe).
[Filter RequestLinear(), may also make it work ok, dont know. (the Linear Access requirement)]
Suggest some other duplicate eliminator.
EDIT: Do you need the ExectDeDup TimesCodes stuff for Variable Framerate ?
SuperLumberjack
16th August 2019, 15:04
No thanks ! It's constant framerate :)
But clearly there is a problem with my videos.
I won't lie to you, it's videos from a video game (of course :D ), "Sonic Mania" in fact.
Sometimes, I do some videos of gameplay, just for fun, often old 2D or 3D games.
I always try to encode my videos in the 2160p resolution (because in 1080p the compression is not very good on YouTube).
But I haven't a powerfull PC, so the simple way to do this is to record a video of the game in the resolution of 848 x 480 (2X the native resolution of the game, because it's pixel art) and then upscale the resolution 2X with PointResize and to the 2160p resolution with a bilinear filter. It's perfectly equivalent to the "Clean" filter in this game (there are 4 filters).
But some cinematics (the videos that I extracted here) are apparently in a native resolution of 1024 x 512. In the game, these videos are simply upscaled to the 1080p or 2160p resolution with a bilinear filter.
So, it's not really nice if I use the these cinematics from my records in 480p. It's why I want the source videos.
On the Steam forums, the method is explained for extracting the data of the game : https://steamcommunity.com/app/584400/discussions/0/1474221865180283239/
So I did it. But the problem with the videos extracted is that some frames are apparently not read correctly as you can see here :
http://image.noelshack.com/fichiers/2019/33/3/1565784033-probleme-videos-ogv-sonic-mania.png
And so there are some frames which are duplicated (even entire sequences sometimes) if I compare with these videos in-game.
But in fact, I think it's too complicated, I won't be able to have the exact same frames, because I even noticed this morning that some frames are missing sometimes :(
But thank you very much for your help StainlessS ! :thanks:
I must find another solution I think...
SuperLumberjack
21st August 2019, 12:12
Hello,
I have a question. I noticed something interesting. It's about a special scaling algorithm that I don't know :confused:
It looks like something between PointResize and BilinearResize, but I think it's sharper than a bilinear filter.
Here is a screenshot of the game Sonic Mania with the "None" filter (yes, it is a filter) :
https://i.lensdump.com/i/itCOlF.md.png (https://lensdump.com/i/itCOlF)
The native resolution of the game is "424 x 240" and then the picture is scaled to a resolution of "1920 x 1080".
I thought that this filter was equivalent to this script :
ImageSource("H:\source.png").convertToRGB24
PointResize(1696, 960)
BilinearResize(1920, 1080)
https://i.lensdump.com/i/itCS4D.md.png (https://lensdump.com/i/itCS4D)
But it's a bit different as you can see here :
https://i.lensdump.com/i/itCePq.md.png (https://lensdump.com/i/itCePq)
Strange no ? :eek:
It looks sharper than the bilinear filter, but it's not a nearest neighbor filter. So what could it be ? :scared:
Here is the source image :
https://i.lensdump.com/i/itCvjA.png
It's funny, because some days ago, I wanted to ask if it's possible to have something between PointResize and BilinearResize, long before I have noticed this ! :)
So, I wanted someting that it's pefectly egal to PoinResize if I upscale a picture 2X, 3X, etc., but with interpolation (but nos as blurry as a bilinear filter and without ringing) if it's for example 2,5X or 4,8X or anything else. So, a kind of linear point resizer... I was wondering if it's possible. And now, I noticed this ! Strange coincidence ! :p
Thanks for your help ! :thanks:
Edit :
You can see better the difference here !
The picture in-game zoomed to 800% :
https://i.lensdump.com/i/itCXjK.md.png (https://lensdump.com/i/itCXjK)
My reproduction :
https://i.lensdump.com/i/itCbqZ.md.png (https://lensdump.com/i/itCbqZ)
A GIF animation to compare :
https://i.lensdump.com/i/itCwMP.md.gif (https://lensdump.com/i/itCwMP)
So, how does it work ? :confused:
SuperLumberjack
21st August 2019, 15:06
The other strange thing is with the fullscreen mode in 720p for example.
In windowed mode with a window size of 3X, the resolution is 1272 x 720 :
https://i.lensdump.com/i/itJK0c.md.png (https://lensdump.com/i/itJK0c)
So in fullscreen mode, we get a resolution of 1280 x 720. We could have expected that the picture is simply stretched with a bilinear filter. But it isn't exactly the case as you can see here :
https://i.lensdump.com/i/itJpBK.md.png (https://lensdump.com/i/itJpBK)
Comparison :
https://i.lensdump.com/i/itJ7oZ.md.png (https://lensdump.com/i/itJ7oZ)
They used another technic to keep a natural image I think, instead of only using a horizontal interpolation. I really don't know how they did ! :confused:
The source image if you have an idea :
https://i.lensdump.com/i/itJH2P.md.png (https://lensdump.com/i/itJH2P)
Some persons noticed the same thing too :
https://www.reddit.com/r/gamedev/comments/70f8t2/pixelart_scaling_at_noninteger_ratios_like_shovel/
https://www.reddit.com/r/gamedev/comments/6ay0qg/better_pixel_scaling_shader/
Edit : It seams that is an association of the Nearest Neighbor filter and the Bilinear filter, as I tried, but it's strange, because the Bilinear filter is different ! And I don't understand the capture of the game in fullscreen mode in 720p, because apparently, there is a horizontal interpolation, but a vertical interpolation too.
Edit 2 : I understood for the 720p in fullscreen. The source image is scaled 4x with Nearest Neighbor (1696 x 960) and then downscaled to the resolution of 1280 x 720. But the bilinear filter still looks different... !
Thanks for your help !
SuperLumberjack
21st August 2019, 16:14
So my only question now is : why are these two Bilinear algorithms different ? :)
It seems that some pixels are shifted differently in fact.
Shouldn't they be exactly identical ? Because bilinear is... linear no ? :D
So what is the most correct bilinear filter ?
I'm curious to know !
Thanks for your answer ! :thanks:
SuperLumberjack
21st August 2019, 17:01
OK. Someone told me that :) :
"The bilinear filter is handled by the GPU in Sonic Mania, so individual GPUs might have slight differences in how they sample texels."
Solved ! ;)
SuperLumberjack
22nd August 2019, 19:29
I still have a question ! :o
Is there a way to get the exact same bilinear filter than my GPUs use ?
Because apparently, my GPU scaling is exactly the same for the Nvidia GPU of my laptop and the AMD GPU of my desktop computer.
But with the bilinear filter of AviSynth, the blended pixels seems juste shifted with the opposite coordinates trough the X and the Y axes :confused:
https://i.lensdump.com/i/itc7Da.md.png (https://lensdump.com/i/itc7Da)
Asmodian
22nd August 2019, 20:05
the blended pixels seems juste shifted with the opposite coordinates trough the X and the Y axes
What? :confused:
wonkey_monkey
22nd August 2019, 20:53
Try:
PointResize(1696, 960)
BilinearResize(1920, 1080, src_top = 0.5, src_left = 0.5)
with various values, positive and negative, for src_top and src_left.
Though really I think you might be on a fool's errand. There's so little difference between any of these. One sprite when rescaled may already look exactly the same on both, if it happens to occupy a different position on screen at the time.
SuperLumberjack
22nd August 2019, 21:11
What? :confused:
Yes, it's a bit hard to explain ! :p
Maybe you will understand better with these 2 images :
https://i.lensdump.com/i/itco3P.md.png (https://lensdump.com/i/itco3P)
The 2nd is a animated GIF ;) :
https://i.lensdump.com/i/itcuNm.md.gif (https://lensdump.com/i/itcuNm)
Try:
PointResize(1696, 960)
BilinearResize(1920, 1080, src_top = 0.5, src_left = 0.5)
with various values, positive and negative, for src_top and src_left.
Though really I think you might be on a fool's errand. There's so little difference between any of these. One sprite when rescaled may already look exactly the same on both, if it happens to occupy a different position on screen at the time.
Thank you ! I will try :)
Yes, I know it's a bit absurd. But it's for the quality of the reproduction. The depth looks a bit different.
SuperLumberjack
22nd August 2019, 21:36
It's almost (minor differences with the RGB values of the interpolated pixels) that with :
PointResize(1696, 960)
BilinearResize(1920, 1080, src_top = -0.25, src_left = -0.25)
:thanks:
But why are they these differences between bilinear algorithms ? :confused:
I would like to understand. Which filter is correct ?
wonkey_monkey
22nd August 2019, 21:45
Neither is "correct." A choice has to be made for the "origin" when upscaling like this, and it's pretty much arbitrary. There may be other differences, but those too will probably be arbitrary.
SuperLumberjack
22nd August 2019, 22:11
OK. Thank you for these informations ! ;)
In fact, I found the (almost) good values with :
BilinearResize(1920, 1080, src_top = -0.20, src_left = -0.20)
It can vary from 1 or 2 units for the RGB values for a same pixel, but I noticed the same thing between the scaling of my Nvidia GPU and my AMD GPU.
But apparently, Nvidia and AMD chose something very close.
So I think it's not very important which values for the bilinear filter ! :p
But I'm glad to have learned something ! Thank you everybody ! ;)
SuperLumberjack
23rd August 2019, 00:04
However, the only thing that surprises me is the fact that Nvidia (or Intel, because maybe the scaling is done by the Intel IGP on my laptop) and AMD, which are rival, decided to use the exact same bilinear algorithm for the scaling... :o
Do you really think that it is a coincidence ? :rolleyes:
Because when I change the values for "src_top" and "src_left", the RGB values can change considerably for the pixels which are impacted, whereas the non interpolated pixels of the image keep the same values as the source.
And so, even if it looks subtle, I personally find that it's the entire depth of the picture which can change.
Shouldn't there be a standard which can be the same for everybody ?
But Nvidia (or Intel) and AMD agree about the values to be used for the bilinear algorithm :)
Maybe for some of you it's insignificant, but recognize that it's a bit strange ! :p
SuperLumberjack
23rd August 2019, 10:08
Hello :)
I compared some bilinear resizers to see if they are different or not, and yes, they are different ;)
I just tested with Photoshop and XnView.
It seems that the bilinear filter of AviSynth is exactly the same as Photoshop (same RGB values too).
But with XnView it's different from my GPU scaling and Photoshop. So I didn't try with other softwares. I have my answer ! :p
I know I'm a bit crazy :D
Thank you very much ! ;)
SuperLumberjack
23rd August 2019, 11:19
Just a question please !
I often asked myself the question : « If I double a picture with PointResize and then I must convert it from the YV24 colorspace to YV12, why isn't the picture identical ? » :confused:
Of course I'm missing something, but in my logic, if I double a picture with PointResize, after having converted the colorspace from YV24 (which is almost identical to RGB24) to YV12 with PointResize for the chroma resampling, the chroma should be identical no ?
But maybe it's because the YUV colorspace doesn't work like the RGB colorspace. Am I wrong ? :)
But how ?
Edit : No. Excuse me ! I should have talked about the YUV 4:2:2 colorspace instead of YUV 4:2:0. But even here it's not identical. Why ?
Asmodian
23rd August 2019, 19:53
The resampling during the conversion is using a wider radius bicubic kernel, try setting it to bilinear.
Use chromaresample="bilinear" or even "point" in the ConvertTo.
Edit:
Of course I'm missing something, but in my logic, if I double a picture with PointResize, after having converted the colorspace from YV24 (which is almost identical to RGB24) to YV12 with PointResize for the chroma resampling, the chroma should be identical no ?
Sorry! I missed you already using Point resize for the conversion. In that case it can only be the chroma placement. Chroma placement is a bit odd, both ChromaInPlacement and ChromaOutPlacement should be investigated. :o
Edit2: How different are they? You cannot do a lossless conversion from RGB to YV24 to RGB (at least when using the same bit depth at each step), there will always be minor differences in the final RGB values.
SuperLumberjack
23rd August 2019, 21:00
OK. So it's a question of chroma placement. Yes, I found strange that the chroma wasn't aligned with the luma. I will explore this settings. Thank you ! ;)
And what algorithm do you recommend for the conversion of the colorspace for classic videos (no pixel art) ? Because I suppose that something smoother than PointResize is better in this case.
Have you ever tried the "UtVideo YUV420 BT.709 VCM" ? I always use this codec for the conversion and because it's lossless. But if I compare the conversion of the colorspace with it, it's less clean than the conversion by default with AviSynth, but it's more natural I find.
It's strange, because I don't know how the chroma is subsampled with this codec. It doesn't match with any of the existant algorithms.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.