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. |
|
|
Thread Tools | Search this Thread | Display Modes |
17th March 2005, 18:18 | #1 | Link |
Registered User
Join Date: Sep 2004
Posts: 9
|
Bug or feature: differences between crop before resize and crop in resize function
Code:
A=BlankClip(width=720,height=8,pixel_type="RGB24",color=$000000) B=BlankClip(width=720,height=560,pixel_type="RGB24",color=$CACACA) C=BlankClip(width=720,height=8,pixel_type="RGB24",color=$000000) SOURCE=StackVertical(A,B,C) # # V1=SOURCE \.SeparateFields() \.Crop(16,4,688,280) \.BicubicResize(576,160,0.0,0.5) \.Weave() # V2=SOURCE \.SeparateFields() \.BicubicResize(576,160,0.0,0.5,16,4,688,280) \.Weave() Last edited by Viperzahn; 17th March 2005 at 18:21. |
20th March 2005, 07:26 | #2 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Viperzahn,
The cropping parameters of the resizer engine are floating point numbers. This allows the resizers to do subpixel shifting of the resultant image. As a consequence of this design the cropping is not a hard crop at the boundary but more an edge limit to the resampler centre point (there is seperate hard limiting at the picture edge). So your V1 clip has a hard boundary 4 pixels in from the edge of the original image, thus there are no Black pixels in the available sampled image area. At the edge the resampler hits a hard boundary and doesn't sample beyond it. For your V2 clip the centre point of the sampler is constrained to be 4 pixels away from the edge of the picture but wing samples are allowed to span beyond this limit right up to the edge of the image. Thus some of the black pixels are sampled in the wings. For cropping off hard artifacts like VHS head noise or leterbox borders always use Crop. For extracting a portion of an image and to maintain accurate edge resampling use the resize cropping parameters. IanB |
1st March 2012, 02:23 | #4 | Link | ||
Registered User
Join Date: Oct 2011
Posts: 11
|
Quote:
And the second question: http://avisynth.org/mediawiki/Spline36Resize Quote:
Crop(0, 132, -0, -132) LanczosResize(720, 304) ??? Last edited by $in0bi; 1st March 2012 at 03:33. |
||
1st March 2012, 05:51 | #5 | Link | ||
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Accuracy is the wrong concept. Both methods are accurate, they just have very different edge behaviour. You must choose the edge behaviour you want.
Quote:
Quote:
|
||
1st March 2012, 12:20 | #8 | Link |
Registered User
Join Date: Oct 2011
Posts: 11
|
Ok, thanks. Resize cropping crops centred on the real image edge and Crop makes it hard without black noise but less precisely, right?
My Input image is a Blu-Ray with the AR 2.35:1 of the film The Departed (2006) Martin Scorcese - you know where you can see it. I see there legible edge, not like some VHS, so is it a hard edge of the input image? Last edited by $in0bi; 1st March 2012 at 16:43. |
2nd March 2012, 03:31 | #9 | Link |
(schein)heilig
Join Date: Jun 2003
Location: Germany
Posts: 512
|
To illustrate the difference, try this script:
Code:
src = BlankClip(width=320, height=240, color=$ff0000).KillAudio().AddBorders(20,20,20,20) a = src.LanczosResize(240, 180, 20, 20, 320, 240) \.Levels(0, 0.0001, 255, 0, 255).Subtitle("resizecrop", align=5) b = src.Crop(20, 20, -20, -20).LanczosResize(240, 180) \.Levels(0, 0.0001, 255, 0, 255).Subtitle("crop then resize", align=5) StackHorizontal(a.AddBorders(0, 0, 20, 0, color=$ffffff), b) StackVertical(src.Subtitle("source image", align=5).AddBorders(0, 0, 140, 20, color=$ffffff), last) AddBorders(20,20,20,20,$ffffff) You can see how with resizecrop information from outside the cropped area is used by the resizer. Look at the dark border around the “resizecrop” rectangle. That is from the black border in the source bleeding into the cropped image. That cannot happen with “crop then resize” because first you cut, then you scale. And information that is not there anymore cannot be used by the resizer. Hence no bleeding. If you want that bleeding effect or not depends, as explained in postings above. P.S.: The effect is greatly exaggerated by Levels(). Otherwise it would be too subtle to notice with the naked eye.
__________________
Brother John When lost in BeSweet's options, have a look at the Commandline Reference. DVD nach MPEG-4 klappt nicht? Verzweifelt? Auf zum Encodingwissen! |
2nd March 2012, 11:16 | #11 | Link |
Registered User
Join Date: May 2006
Posts: 957
|
What? His image shows the effect this thread has been discussing. The only borders he adds are the black ones to the "source" clip and then the white ones everywhere else so he can make one image.
__________________
x264 log explained || x264 deblocking how-to preset -> tune -> user set options -> fast first pass -> profile -> level Doom10 - Of course it's better, it's one more. |
2nd March 2012, 11:40 | #12 | Link |
Registered User
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,407
|
It is not a matter of more or less precise. It is a matter of what you want. If you are cropping non-video information, like the black boarders in the example, you want to use crop. If cropping video information, such as to change aspect ratio while resizing, resize cropping keeps more information. You don't want to keep this information unless it is real video information and it only affects the outermost few pixels.
|
2nd March 2012, 16:00 | #14 | Link |
(schein)heilig
Join Date: Jun 2003
Location: Germany
Posts: 512
|
But the original image does contain the black bars, look at the example! The difference is this: Resizecrop can use information from outside the crop area in the interpolation process of edge pixels. That leads to the bleeding effect. It always happens, not only with black bars. Crop+Resize can not use information from outside the crop area in the interpolation process.
Forget about more or less information in the output image. That’s not the point. The important difference is that edge pixels contain different information.
__________________
Brother John When lost in BeSweet's options, have a look at the Commandline Reference. DVD nach MPEG-4 klappt nicht? Verzweifelt? Auf zum Encodingwissen! |
3rd March 2012, 01:05 | #15 | Link | |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Quote:
Have a really good hard close look at Brother John's excellent image comparison of the 2 cases. Copy his script and vary it to see how various changes effect the result. If you were cropping a 4:3 section from the centre of the original and did not want the black borders to influence the top and bottom but did want the image side pixels to influence the left and right side you would do something like this :- Code:
... # 1920x1080 source, 2.35:1 letterboxed Crop(0, 132, 0, -132) # Crop off black borders LanczosResize(640, 480, 413.33, 0, -413.33, 0) # Select 4:3 centre window The forums are the right place for support questions, PM's are for in private exchanges of confidential information, i.e. password, email addresses, phone numbers, etc. Also understand many members only read the forum every other day or so, some maybe only weekly, it is grossly impatient to expect answers within a few minutes of your posting. Prompting to read your posts via a PM should be reserved for at least 3 or 4 days of idleness. |
|
3rd March 2012, 06:25 | #16 | Link |
Registered User
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,407
|
I am sorry if my answer was confusing.
If cropping black boarders do not use resize cropping. The exact same math is used to do the resize either way. The difference is weather the uncropped or cropped image is used when doing the resize. Last edited by Asmodian; 3rd March 2012 at 06:33. |
3rd March 2012, 13:57 | #17 | Link |
Registered User
Join Date: Oct 2011
Posts: 11
|
IanB, so why don't you extend possibilities of the Crop? By using Crop I can chop only for two pixels, for example, Crop(0, 2, 0, -0), Crop(0, 4, 0, -0) and etc. Some images like some films need only one pixel to cut, for example, Crop(0, 1, 0, -0) and if I'll cut two pixels I'll cut the the image of the film picture. By the way Resize-crop can crop for 1 pixel.
PS. Does anybody concordant with me that it would be very useful innovation? Last edited by $in0bi; 3rd March 2012 at 14:08. |
3rd March 2012, 14:49 | #18 | Link | |
LaTo INV.
Join Date: Jun 2007
Location: France
Posts: 701
|
Quote:
|
|
3rd March 2012, 14:53 | #19 | Link |
(schein)heilig
Join Date: Jun 2003
Location: Germany
Posts: 512
|
Crop “step size” depends on the colour space you use. Most likely that is YV12, because that’s what almost every video uses. YV12 needs even crop values (“mod2”) because of the way it stores colour. To an extent you can work around that restriction with resizecrop. But the final width and height must be mod2, so Crop(0, 1, 0, -0) isn’t possible.
RGB doesn’t have such restrictions. But virtually every common delivery format (all the MPEGs, VC-1, VP8 …) relies on YV12. That means even when you use RGB in AviSynth you’ll probably have to convert to YV12 for the video encoder anyway.
__________________
Brother John When lost in BeSweet's options, have a look at the Commandline Reference. DVD nach MPEG-4 klappt nicht? Verzweifelt? Auf zum Encodingwissen! |
3rd March 2012, 16:51 | #20 | Link |
Registered User
Join Date: Oct 2011
Posts: 11
|
I easy can do with Resizecrop something like this
LanczosResize(720, 304, 1, 131, -1, -131) #not mod2 So may be exist some way to educate Crop make the same in the next version of the avisynth? Last edited by $in0bi; 3rd March 2012 at 18:07. |
|
|