View Full Version : RoboCrop - unsymmetrical cropping ?
Hotte
5th February 2020, 07:40
Hi,
I am trying to use RoboCrop to cut out a 648x480 clip which sits in the center of a 1920x1080 export file from an NLE. After applying RoboCrop() I am getting a 648x480 crop. Perfect.
However if (for effect reasons) I decenter the 648x480 clip e.g. 400 px to the left so that the left black frame is a lot thinner than the right frame, I am getting a crop where the left frame has been removed (perfect), but the right black frame is 1036 px wide. So no cropping of the right black frame and the clip is now 1684x480.
I had hoped to again get a 648x480 crop (to speed up subsequent filtering) and to reposition the clip at the end of the process.
Is this sth that cannot be done with RoboCrop or are there any parameters I have missed to find ?
StainlessS
5th February 2020, 08:05
Hotte, Ask a moderator to move your thread into the Usage forum, and delete this thread.
I gave a solution in Devs. Am going to beddy-byes.
Hotte
15th February 2020, 21:16
Hi StainlessS,
I have experimented a lot with RoboCrop and the new parameter, ScanPerc=99.0 which works very well. However I cannot make it correctly crop the following effect clip:
A short text (title) in the screen center. A small pic (starting at about 5x5 pixels) appears in the upper right corner continuously approaching the title region while growing until it fully covers the title.
Whatever parameter (baffle, thresh, ignore...) I choose in combination with samples=0: RoboCrop only "detects" the pic as image when it has grown to some estimated 50x50 px. Below it crops the title only. If I play with thresh I can only achieve a no crop result.
I know I cannot expect this to work since it is an unorthodox case. But maybe you´ve got an idea for me ?
EDIT: Found out that using Start=0 lets the pic to be detected a few frames earlier due to Auto-Intro skipping (?).
Having now tried out all the parameters I am missing a kind of "sensitivity option" concerning the minium number of "remote pixels" above threshold to be considered as being part of the image. If this is technically possible it would be perfect for speeding up Avisynth post-processing of any NLE output. There is absolutely no noise in this black space into which the NLE places the different video objects (downscaled clips, titles, color mattes...) according to keyframe rules. So sensitivity could be turned down to zero since any non-black pixel is always part of the image.
StainlessS
16th February 2020, 03:03
I'm unclear what the requirement is, post script and start/end images [use Postimage.org, no acc required].
Hotte
16th February 2020, 09:42
Thanks you StainlessS for looking into this, although I know it is perhaps over the top...
I have prepared an extract of 17 images of the whole sequence which originally consists of 216 images:
https://postimg.cc/gallery/3gtexx0x6/
Putting them together to a short clip yields the following result:
https://postimg.cc/T5XYj1FF
The code here is:
clp = Avisource(FILNAM)
clp = RoboCrop(clp,show=true,start=0,end=clp.framecount-1,samples=0,ScanPerc=99.0,thresh=0,Laced=false)
The flying image shows up in the crop only from image #10 in the extract, which is "hotte055" in the original.
In the original the first glance of the flying image appears from "hotte010", which is image #2 in the extract, and is clearly visible at the latest from hotte014 which is #4 in the ectract
The result is only slightly different if I use all the 216 images: The flying image appears a bit earlier (somewhere between what is #8 and #9 in the extract) and #15 in the extract would be fully visible.
I do not know if you will be getting exactly the same result when downloading the pictures because postimage recompresses the original tiffs to smaller png, but I'd say the basic behaviour could be the same.
Thanks again!
StainlessS
16th February 2020, 11:58
And what area exactly is it that you are expecting to crop [especially when there aint no small image there at all] ???
Image + text area ???
Still no idea what you are wantin' to do, but suspect it aint never gonna work anyway, but do tell just the same.
And you are wantin' to crop single frames at a time [ie all different sizes], [RoboCrop applies same cropping to entire clip] ?
EDIT: If you are just wanting to find total area where non black pixel occurs at any time, then is probably easier to do crop by hand.
EDIT: Your 2nd link is just an image, not a clip [PostImage only hosts images].
Hotte
16th February 2020, 12:51
Imagine these 17 images being the whole clip. I am looking for the cropping coordinates that cover the whole scene (all 17 images) without loosing any non black information.
It is the crop which finds its top right corner with image #2 or #3 and its botttom left corner with image #14. Let's estimate this crop to be sth like crop(100,30,1819,1049). That's less than 1920x1080 and so, subsequent filtering will be faster.
This is an extreme example. The majority of subformats like 720x576 in a 1920x1080 output are being downscaled to their original format before being filtered and they do not move or move only a little. Making a crop which is only 1/3 or 1/4 of 1920x1080 intensively speeds up the process.
Of course making the crop manually will do it. The issue is that NLE output may consist of some 500 single clips and you never know wether titles have been added or some clip moves around. So there is a need for automated cropping.
The beauty of RoboCrop is, that it does an excellent job to find the desired coordinates in 95% of the cases.
It only fails in some extreme cases and that is small objects. So my question was, if there is some parameter to increase sensitivity or any other idea.
If not I well understand that RoboCrop was not intended for this kind of application.
The second link was only to show the cropping coordinates at image #10.
Thanks!
StainlessS
16th February 2020, 13:57
Nope sorry, no can do.
I could do some mod, but dont fancy spending quite a lot of time doing it, just to save you a coupla minutes doing it by hand.
Hotte
16th February 2020, 17:21
This is absolutely ok, StainlessS. My intention was only to check if there is a simple tweak or parameter I may have overseen.
You have already implemeted ScanPerc and that is a great gift for it makes it possible to make RoboCrop / RT_QueryBorderCrop a most useful addition to my permanent setup as it solves 95% of the cases automatically which is great!
I remember the support you gave me using ExactDedup some time ago. With your help ExactDedup has become an indispensable and revolutionary part of my setup.
Just for curiosity: What do you think could be the reason that the flying image is partly not being seen by RoboCrop ? Is it because it is moving ? Or because it is small ? Or both ?
I tell you what I am trying to do to complete my setup while carrying on using RoboCrop: What you see in this example is a transition between to scenes (the title and the baby). I remember that I have a flag that marks "contains transition" with every exported clip. I will make my automatic script-builder to read this flag and, if true, to avoid applying RoboCrop and process the clip fullsize. This should make an acceptable workaroud.
So thank you again for your kind help.
StainlessS
16th February 2020, 17:41
Well for a start, RC, uses AverageLuma of individual Rows/Columns of pixels [not good at seeing a single pixel(or just a couple)],
is necessary for avoiding noise, also Baffle setting requires multiple scanlines (default 4) to all pass as image (all above some thresh),
we dont detect border, we can only detect image, and expand outwards until what is left is border.
[It dont work exactly like that, but I guess is good enough description, is a bit more compilcated]
I guess it could be possible to eg measure difference between min and max pixel in scanline, and detect on that, but would be pretty much
useless for anything other than your requirement.
EDIT: "bit more complicated"
Well lets say [for top border only] we start with Image_Top at 49% toward frame center.
We scan from frame top, downwards until we find image via AverageLuma and Baffle, Image_Top cursor is then moved up to that position.
At Next sample frame we do same again, and then again, and again, so that Image_Top moves upwards as more image is detected with each sample frame.
So, we scan downwards, and image grows upwards, and remainder is border.
Hotte
16th February 2020, 17:58
Uuuh that sounds pretty complicated to me. Don´t do it, really!
Just to explain my setup a little if you are interested: I am using Edius NLE. I wrote a dialog which you can call in Edius to mark each clip (there can be hundreds of them in one project) with individual filters that are missing and should be applied in post. Some Avs-filters are sooooo great!
At the end I export the project out of Edius as 1 AVI-File. Now my splitter comes in: It cuts every single clip out of the AVI and creates an individual avs-Script with the desired filters.
If the Export-AVI is 1920x1080 it will contain all sorts of formats, also many subformats like 720x576 or 640x480. If you e.g. mdegrain these in fullsize post-processing takes some 4x longer. This is where RoboCrop comes in: Automatically detect the relevant area (which is not always the center ;)), apply the filters and then put the filtered area back onto a BlankClip in the right position. Hundreds of clips are being automatically processed this way.
At the end all the filtered clips are being reimported and glued together to form one new video.
StainlessS
16th February 2020, 18:03
Now that sounds complicated. :)
Got to see a man about a dog, down the pub now, bye.
Hotte
16th February 2020, 18:06
Cheers!
Hotte
2nd June 2021, 11:01
Hi StainlessS,
I am permanently using RT_QueryBorderCrop and ExactDedup in their 64-bit Versions in AVS+.
Currently I am moving more and more towards YUV422P10. Documentation (Avisynth-Wiki) forbodes they both do not preserve HBD colour formats.
Since I use RT_QueryBorderCrop for detection only and crop with avs-crop this should be 10-bit save (I do not need 10-bit precision for detection only).
But what about ExactDedup pass1/2 ?
StainlessS
2nd June 2021, 22:35
There should be no probs using RT_QueryborderCrop on HBD converted to SDB.
(converting all my stuff to HBD is a big prob, just way too lots to do. [ I dont even wanna thing bout the docs never mind the code]).
ExactDedup, reports exact dupe only if is bit for bit identical, so if you convert HBD to SBD, might not be totally identical,
but nigh as dammit the same [probably], I only did a re-compile of ExactDeDup, I really dont feel in any way responisble for it or for updating it.
StainlessS
3rd June 2021, 14:36
OK, I guess HBD ExactDedup would be an easy-ish task, I'll do it.
Hotte
3rd June 2021, 17:52
What ? Are you sure ???
I've always said, that StainlessS is my man!
Your contributions to my workflow are and always have been essential.
I am happily looking forward to this!
StainlessS
3rd June 2021, 18:16
Halfway done.
Replacing the usual Info.h metrics renderer with DDigit v2.0 metrics renderer, first plugin with it implemented.
[implemented about 12 months ago, but not used it yet].
Used in Pass=2 where Show = True.
EDIT: Posted update here:- https://forum.doom9.org/showthread.php?p=1944275#post1944275
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.