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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st July 2010, 21:51   #21  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 262
<quote>"mask is full" means that your mask is "full white" after cropping. </quote>

Ah! I understand now.

From looking at the source, I could see that it should only say "Mask full" if the mask was 100% white, but my mask isn't (I thought)... but I was overlooking the "after cropping" detail. For my first experiments, I'm using a simple white rectangle against full black as my mask, and in my keenness for speed, I see that with my loc="" string I've cropped well inside the white rectangle.

<quote>Have you tried Load_Stdcall_PluginM</quote>
Not yet. I'll try the newer version with that later.

Thanks for your help.
pbristow is offline   Reply With Quote
Old 16th September 2010, 01:20   #22  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 4,829
@Reuf Toc

Love your script, tried the newer alternative (dont off hand remember name)
but prefer yours. Can I though suggest that with your next script update, you include
the below mod:

Code:
            catch (dummy) 
              {
              	show=true
              	in2.analyzelogo(Masque).trim(0,-1).converttoRGB32
              	imagewriter(ID,0,1,"ebmp")      
              }""")
Namely the "Show=true" line.

makes it much more usable and would obviate the need for me
to replace it when you do make an update.

Forces the script to actually save the bitmaps, dont really
know how it's supposed to work without it.

Also, can I suggest that you and others viewing this thread
see update just posted minutes ago here:

http://forum.doom9.org/showthread.php?t=154559

Have had great success using my script as a post processor
to AvsInpaint, InpaintFunc combo.

thanx, be good
__________________
I sometimes post sober.
StainlessS@MediaFire ::: StainlessS@SendSpace

Last edited by StainlessS; 16th September 2010 at 14:13. Reason: remove "C" style ; in source
StainlessS is offline   Reply With Quote
Old 22nd February 2011, 18:10   #23  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 4,829
@Reuf Toc

See this post for future problem in InPaintFunc.avs

http://forum.doom9.org/showthread.ph...55#post1479855
__________________
I sometimes post sober.
StainlessS@MediaFire ::: StainlessS@SendSpace

Last edited by StainlessS; 24th February 2011 at 05:28.
StainlessS is offline   Reply With Quote
Old 26th April 2011, 01:05   #24  |  Link
Beak
Registered User
 
Join Date: Jun 2003
Posts: 127
Hello. This is my first try at logo removal. I am marginally familiar with scripting but have never seen the error I am getting.

I have AVSInpaint.dll in my Avisynth 2.5 plugins folder. The script is as follows

import("C:\Program Files (x86)\Winnydows\XviD4PSP5\dlls\AviSynth\functions\AudioFunctions.avs")
import("C:\Program Files (x86)\Winnydows\XviD4PSP5\dlls\AviSynth\functions\VideoFunctions.avs")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\AVSInpaint.dll")
Import("C:\Program Files (x86)\AviSynth 2.5\lsfmod\InpaintFunc.avs")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\FFT3dGPU.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\MT.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\MCTemporal Cleaner\mt_masktools-25.dll")

LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\MCTemporal Cleaner\RemoveGrainSSE3.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\MCTemporal Cleaner\RepairSSE3.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\lsfmod\RSharpen.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\lsfmod\WarpSharp.dll")

Import("C:\Program Files (x86)\AviSynth 2.5\lsfmod\LSFMod.avs")
DirectShowSource("G:\In the heat of the night\2011_4_24_15_58_17.avi", fps=23.976, convertfps=true)

ConvertToYV12()
Trim(1168,159461)


MT("""InpaintFunc(last, mask="G:\In the heat of the night\Logo White.bmp", loc="br", AR=16.0/9.0, mode="both", speed=10, ppmode=3, pp=75)""", threads=4, overlap=8)

I get an error for line 3 that says "AVSInpaint.dll is not an Avisynth 2.5 plugin" Does this plugin only work for 2.6? Is there a 2.5 version available.

My LSFMod scripts work etc. I just hadn't added the parameters for LSFMod yet.

I would really appreciate any help that you can offer. Thanks BK

Last edited by Beak; 26th April 2011 at 01:07.
Beak is offline   Reply With Quote
Old 26th April 2011, 01:40   #25  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,373
Quote:
Originally Posted by Beak View Post
I get an error for line 3 that says "AVSInpaint.dll is not an Avisynth 2.5 plugin" Does this plugin only work for 2.6? Is there a 2.5 version available.
AVSInpaint.dll is not a standard plugin (it is writtten in C, not C++) and must be loaded by
LoadCPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\AVSInpaint.dll")
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 27th April 2011, 00:36   #26  |  Link
Beak
Registered User
 
Join Date: Jun 2003
Posts: 127
Thank You. The script now loads with the following error

Mask dimension does not match that of input file.

I checked and they are both 1920X1080.

Any hints for this?

Last edited by Beak; 27th April 2011 at 00:39.
Beak is offline   Reply With Quote
Old 7th April 2012, 15:28   #27  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Fizick, AMSS0815, thank you for the great work in creating inpaint tools; and Reuf Toc, StainlessS, thanx also for improving appropriate functionality. I'm not a code-writer, so having terrific difficulties to further adopt your tools according to current needs, and hope for effective help.

The problem is with semi-transparent logos, they eliminated under AVSInpaint+exInpaint+Rm_Logo, their inside fields became perfectly transparent but there are glass-like remainders after their borders. At first, I presumed that is the result of encoding artifacts (slight ringing, graining, so on), and treated the logos under variable customizations, including different logo-templates, but nothing could help. Now I guess, the glass remainders caused by aliased edges in the Pre-multiplied Alpha Channels (http://faculty.mdc.edu/jvanvori/Docs...-mystified.pdf) that probably exist in my HDTV-source.
Please, help to find out the right way:

1) Is it correct when I create RGB24 logo mask, or RGB32 is needed for correct operation?
2.1) Can this problem be solved if we change colorspace or matrix when creating "Logo Color" and "Logo Alpha"?
2.2) May be the key is RGBA convertion when creating "Logo Color" and "Logo Alpha" templates?
3.1) Is it feasible at all to eliminate the Pre-multiplied Alpha Channels using your tools, and which tunings to activate in this case?
3.2) If not, are you going to add such functionality?
4) Is it helpful to debug the "Logo Color and Alpha" picture in After Effects, and how to do this?

Sorry for my poor English. Thank you in advance for any help to the right way.

Last edited by shark000X; 7th April 2012 at 18:34.
shark000X is offline   Reply With Quote
Old 8th April 2012, 13:40   #28  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi shark000X,

I can only speak for AVSInpaint here. I don't really understand what you're doing. I guess you used AnalyzeLogo to get the logo's image and alpha mask. Is your source RGBxx or YV12?

> 1) Is it correct when I create RGB24 logo mask, or RGB32 is needed for correct operation?
What is your "logo mask"? In AVSInpaint there are several functions which accept "Mask" arguments, but they will reject RGB24 Mask arguments.

> 2.1) Can this problem be solved if we change colorspace or matrix when creating "Logo Color" and "Logo Alpha"?
If you have to convert the colorspace of the logo's alpha channel, always use Matrix="PC.601" (see DeblendLogo documentation). If you have to convert the colorspace of the logo's image, you're probably doing something wrong.

> 3.1) Is it feasible at all to eliminate the Pre-multiplied Alpha Channels using your tools, and which tunings to activate in this case?
I don't understand this question. The DeblendLogo function eliminates the pre-multiplied alpha channels, frame by frame. This process is slightly faster if the Logo and Alpha arguments are clips with one frame only (see DeblendLogo documentation). Besides that, I don't see how this might be done better.

> 4) Is it helpful to debug the "Logo Color and Alpha" picture in After Effects, and how to do this?
No. I tried this (with other software), but I never managed to improve the output of AnalyzeLogo by hand. If you feel that your alpha mask is bad, you might play around with the DeviationWeight parameter (see doc). If your clip is YV12, SubsamplingWeight might also improve your alpha mask.

> their inside fields became perfectly transparent but there are glass-like remainders after their borders.
Is there a glass-like border of the shape of the logo, or is there a border of a rectangular shape (where you cropped your video when doing the logo removal stuff)? In the latter case, I guess you forgot Matrix="PC.601" somewhere. In the former case, try to improve the output of AnalyzeLogo with these ideas:
  • Make sure the logo is *completely* contained in the "Mask" which you provide to the AnalyzeLogo function (the mask, where you "suspect the logo to be", according to the docs). I guess you drawed this mask by hand in your favorite image editor. Expand this mask by a few pixels in all direcitions ("dilate" it, in image processing speek).
  • Crop away all non-image parts of your video (black bars at top/bottom of screen) before handing it over to AnalyzeLogo. If you cannot, include them in the "Mask" as well (see doc).
  • Areas which are legitimate movie content and not altered by any logo/whatever should not be covered by AnalyzeLogo's "Mask" argument. They serve as reference material to estimate the alpha mask.
There is also a chance that your glass-like border comes from mosquito noise (see wikipedia). This noise is like an alpha mask which changes in each frame and which cannot be fixed with AnalyzeLogo. Last resort might be to set mask this border by hand and cover it with InpaintLogo.

-- AMSS0815
AMSS0815 is offline   Reply With Quote
Old 9th April 2012, 02:16   #29  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Hi AMSS0815, thank you for fast reply!

Just to avoid some misunderstanding (my fault), here is additional information:

5) The video source: 1280x720, YV12, TV.709, 4:2:0 (it doesn't contain any non-image parts at top/bottom of screen);
6) I provide *.bmp (RGB24 colorspace - is here possible mistake?) as the "Mask" argument to the AnalyzeLogo. The BMP contains the logo image (pure white template) surrounded by pure black background. The source logo is completely contained in the "Mask", moreover tried to vary its dilating range. Legitimate movie content is not covered by the AnalyzeLogo's "Mask" argument, except the dilated area.
7) The Logo and Alpha arguments are clips with one frame only (both BMP RGB24) processed further with assistance of the Rm_Logo.avs (Spuds' subfunction).
8) As a whole result of process, the source logo is correctly replaced by legitimate underlayer but the shape of source logo turned into glass-like border.

Now, after close examination I see that both subfunctions (Rm_Logo by Spuds, and InpaintFunc by Reuf Toc) operate the DeviationWeight and SubsamplingWeight parameters under default values (0.5). May be this is the graal for my situation - to tune both "Weight"s, starting with 0.25 SubsamplingWeight... Could you tell me please the reasonable measures for the DeviationWeight?

Nevertheless, the above-mentioned "Last resort" remains under my consideration, though it would be in history - I've tried to set a mask over the border and cover it with Inpaint in such a (perhaps stupid) way:
  • created an additional logo template where only the shapes are colored in white;
  • utilized the Logo.vdf to mix the additional logo as new semi-solid alpha channel into the source logo;
  • placed the Logo.vdf function right before the AnalyzeLogo function in the same avs-script.
Finally, the process was much-much-mucho slower, and the result was not satisfactory due to extensive blurriness. This is why I asked you about debugging (or "editing" may be more correct) the "Logo Color and Alpha" picture in After Effects. So, a specifying question:

9) For the above "to set mask this border by hand" - do you mean a simple painting (Photoshop or else) of white boarders in the Alpha-mask.bmp created by the AnalyzeLogo?

Thank you for support, AMSS0815. My mind is clearing up under your suggestions

Have a nice day!
shark000X is offline   Reply With Quote
Old 9th April 2012, 23:56   #30  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi shark000X,

Quote:
Originally Posted by shark000X View Post
I provide *.bmp (RGB24 colorspace - is here possible mistake?) as the "Mask" argument to the AnalyzeLogo.
How do you get this file into AviSynth? With ImageReader/ImageSource? Inside AviSynth these are always clips (possibly with one frame only). Use AviSynth's Info function to determine the colorspace of a clip. Well, AnalyzeLogo would fail if the Mask isn't RGB32 (or YUY2/YV12), so it probably is.

Quote:
Originally Posted by shark000X View Post
7) The Logo and Alpha arguments are clips with one frame only (both BMP RGB24) processed further with assistance of the Rm_Logo.avs (Spuds' subfunction).
What exactly happened with the output of AnalyzeLogo (which I presume was a clip with one 1280x1440 frame) before it became the input of DeblendLogo? I recommend to split the output of AnalyzeLogo with Crop into two frames (1280x720) and save them with ImageWrite as ebmp files. Yes, ebmp, not bmp (see my Demo.avs). ebmp is something like a AviSynth-only format, it can save anything, even YV12, and it reduces the chances that the brightness of your mask is modified in some conversion steps somewhere. I cannot comment on what Rm_Logo does with the logo/alpha mask. But I recommend to (temporarily) skip this "processed further" step.

This is really important! If you convert Y**<-->RGB** colorspaces with the output of AnalyzeLogo before handing the result over to DeblendLogo, you risk that the Y-levels of the mask get converted to a different scale somewhere.

Quote:
Originally Posted by shark000X View Post
Now, after close examination I see that both subfunctions (Rm_Logo by Spuds, and InpaintFunc by Reuf Toc) operate the DeviationWeight and SubsamplingWeight parameters under default values (0.5). May be this is the graal for my situation - to tune both "Weight"s, starting with 0.25 SubsamplingWeight... Could you tell me please the reasonable measures for the DeviationWeight?
Errr, don't expect too much here. I picked the default 0.5 because it gave me the best results for my own experiments. I always felt that DW=0 and SW=1 would be the natural choice here, but the results were bad. You might try values like 0.0, 0.1, 1.0 and maybe 1.5, (with 0.5, that's 25 combinations for both parameters together), but I'd be surprised if it solves your problem.

Quote:
Originally Posted by shark000X View Post
Nevertheless, the above-mentioned "Last resort" remains under my consideration, though it would be in history - I've tried to set a mask over the border and cover it with Inpaint in such a (perhaps stupid) way:
  • created an additional logo template where only the shapes are colored in white;
  • utilized the Logo.vdf to mix the additional logo as new semi-solid alpha channel into the source logo;
  • placed the Logo.vdf function right before the AnalyzeLogo function in the same avs-script.
Finally, the process was much-much-mucho slower, and the result was not satisfactory due to extensive blurriness. This is why I asked you about debugging (or "editing" may be more correct) the "Logo Color and Alpha" picture in After Effects. So, a specifying question:

9) For the above "to set mask this border by hand" - do you mean a simple painting (Photoshop or else) of white boarders in the Alpha-mask.bmp created by the AnalyzeLogo?
Yes. But I really don't see for what you use Logo.vdf (the VirtualDub Logo plugin?) here? I am talking about an additional mask here. You still use DeblendLogo as described above with the (unmodified) output of AnalyzeLogo. You use your favorite image editor to open any mask, or a screenshot of a frame with that glassy border, and then you draw a mask which covers the glassy border (and nothing else) by hand. It should result in a file that looks like a white ring with black interior and black exterior. This mask you save in a new file. Then you apply InpaintLogo to the output of DeblendLogo and feed the new (ring-like) mask as one-frame-clip "Mask" into InpaintLogo.

Another idea: Maybe the chroma subsampling is guilty here. I don't think so, but check what happens if you start with your clip converted to RGB24.

And a sidenote: I assume you do your experimentation just with a small part of the clip. Running AnalyzeLogo is a time-consuming operation! So if you want e.g. play around with the results of different Weight parameters, you might want to use AviSynth's SelectEvery filter to reduce the number of frames analyzed (which of course reduces the quality of the output of AnalyzeLogo). It is also legitimate to crop away parts of the movie that are far away of the logo, such that the Mask you provide to the AnalyzeLogo function occupies approx 1% of the frame's area.

Maybe you can post some pictures (of masks and logos and a glassy border). I'm still not sure if I understand what you're doing.

Another sidenote/disclaimer: I stopped using (Windows and) AviSynth years ago, so my hints are purely theoretical.

-- AMSS0815
AMSS0815 is offline   Reply With Quote
Old 11th April 2012, 20:25   #31  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Hi AMSS0815,

Quote:
Originally Posted by AMSS0815 View Post
...you might want to use AviSynth's SelectEvery filter to reduce the number of frames analyzed (which of course reduces the quality of the output of AnalyzeLogo). It is also legitimate to crop away parts of the movie that are far away of the logo...
I've saved a few % of the source movie into a separate experimental clip to reduce the number of frames as they be 100%-analyzed, so the quality of the AnalyzeLogo output is not reduced by partial analysis. Also I've cropped away the far-away-parts of the movie as follows: L=1040, T=0, R=0, B=-580 (240x140 input to the AnalyzeLogo).

I tried to play with the DeviationWeight and SubsamplingWeight, but failed to solve my problem, you were right as to their values.
Unfortunately, any code-writing is still complicated for me, so further I need to go through appropriate particles of a script in different variants (please check if they are legitimate or not) to meet the above specifying questions of yours.
Quote:
Originally Posted by AMSS0815 View Post
How do you get this file into AviSynth? With ImageReader/ImageSource?...
AnalyzeLogo would fail if the Mask isn't RGB32 (or YUY2/YV12), so it probably is.
...........
Another idea: Maybe the chroma subsampling is guilty here. I don't think so, but check what happens if you start with your clip converted to RGB24.
I wonder, is it worthy here to change colorspaces another way or/and not to crop the analyze clip at all (?):
Code:
# We crop the analyze clip and set a percentage for speed  
cropped     = clip.crop(L,T,R,B)
snipSize    = round( framecount( cropped ) / (framecount( cropped ) * (percent / 100.0) ))
AnalyzeClip     = ( percent != 100 ) ? cropped.SelectRangeEvery( snipSize, 1 ) : cropped
# ...........
# We provide the RGB24 *.bmp (C1 above) as the "Mask" argument for analysis,
# the corner of interest is cropped out
logo_mask   = imagesource(Mask,start=0,end=1)
logo_mask   = logo_mask.crop(L,T,R,B)
logo_mask   = logo_mask.ConvertToYV12(Matrix="PC.601")
logo_mask   = logo_mask.DistanceFunction(255/deblendfalloff).Greyscale
# ...........
# We clean the analyze clip to improve results
AnalyzeClip = (IsYV12(AnalyzeClip)) ? AnalyzeClip : AnalyzeClip.ConvertToYV12
AnalyzeClip = AnalyzeClip.TTempSmoothF(maxr=2,lthresh=256,cthresh=256,scthresh=255).ConvertToRGB24()
# Is it better here to use ConvertToRGB32() instead of ConvertToRGB24(), or leave it without any?
#
# ...........here we check if a resulting ebmp exists or if it has changed
# We perform the logo analysis
{
  AnalyzeClip.AnalyzeLogo(logo_mask)
  # and save the resulting frame
  Trim( 0, -1 )
  ImageWriter( "AnalyzeResult", 0, 1, "ebmp" )
}
When I rename the resulting *.ebmp into *.bmp (that's why it was earlier called BMP) I can see its properties -- 240x280 RGB24, the Avisynth Info() referring to the *.ebmp shows me the same properties.
Quote:
Originally Posted by AMSS0815 View Post
What exactly happened with the output of AnalyzeLogo... before it became the input of DeblendLogo?
...........
This is really important! If you convert Y**<-->RGB** colorspaces with the output of AnalyzeLogo before handing the result over to DeblendLogo, you risk that the Y-levels of the mask get converted to a different scale somewhere.
Code:
# We split the color map and the alpha channel from the resulting ebmp
AssumeFPS(AnalyzeClip.FrameRate)
LogoColor = Crop(0,0,0,last.Height/2)
LogoAlpha = Crop(0,last.Height/2,0,0).ConvertToYV12(Matrix="PC.601")
# We use MaskTools.v2 to mark pixels that cannot be deblended
LogoAlpha.Invert.mt_lut(expr="x " + " " + string(alphatorepair) + " " + "< 255 0 ?").mt_expand.mt_inflate
RepairMask = ( RepairRadius > 0.1 ) ? DistanceFunction( 84.0 / RepairRadius, PixelAspect=par ) : last
Instead of MaskTools (the last 2 strings of above script) I tried to use the particle from your Demo (but the problem was not eliminated):
Code:
# Prepare repair mask (marks pixels that cannot be deblended)
LogoAlpha
Invert
Levels(AlphaToRepair,1,AlphaToRepair+1,255,0,false)
(RepairRadius>0.1)?DistanceFunction(127.0/RepairRadius):last
Levels(127,1,128,0,255,false)
Greyscale
RepairMask = last
Graphics and gestures may be a better way to communicate for a non-English speaker as I am, so please excuse me for not providing pictures from the very beginning, that would save your time.

Here is a frame of my source (see A below) -- the logo is really annoying if untouched; btw, the movie needs some color denoise, I did it but couldn't help the problem we discuss here. The logo seems to be removed (B below) with your magic tool when I provide the "Mask" argument (C below) to the AnalyzeLogo followed by simple deblending (no inpainting, no extra tunings with "weights" or else):
A1> B1>
C1>
But under a closer look we can find unblended shapes of the logo (A below; it undergone triple upsampling for a comfortable look). Anyway, the result would be acceptable if only the shapes were not so intense against the deeply dark and light backgrounds (B below) over and over again, though disappearing within the contrasting light areas (C below):
A2> B2>
C2> D2>
The above B and C together is a good example of the glass-like effect (the opposite shapes of the logo change their luminance antithetically when crossing over dark and light areas) that goes through all the movie. Your magic tool, as I see, is strong enough to deblend the whole logo without distructive inpaintings, but something disturbs the ability Or is it really the mosquito-noise in my source (D above)?

Thank you.
Waiting for your wisdom and expertise.
Have a good time.

Last edited by shark000X; 12th April 2012 at 09:32.
shark000X is offline   Reply With Quote
Old 12th April 2012, 09:53   #32  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi, I'm quite busy at the moment and will have a closer look this (UTC-)evening or at weekend. Just a few quick thoughts:
  • The logo itself looks "good", i.e., I have the feeling it should be easy to remove it. I cannot see dynamics though. Do you have the feeling that it changes from frame to frame, maybe in front of a bright background?
  • I cannot see any mosquito noise on your A1 frame, so that's not a problem.
  • You wrote something about color denoising. Try to put any such steps behind the delogo step. Linear filters (brightening etc.) shouldn't be a problem, but e.g. AviSynths spatial denoiser will modify the logo such that it can no longer be deblended by a simple linear map as my filter does it.
  • Your initial mask C1 looks OK. However: Inflate it by another 8 pixels.
  • You wrote you saved a small clip to a separate file. Try to avoid such steps, especially if they involve loosy compression. Always work with the original clip in AviSynth, i.e. the raw material which was produced by your DVB hardware or downloaded from Internet or whereever it came from. If you have to transform it with special software because it is a format not readable by AviSynth, do this with highest possible quality setting. In AviSynth, if you want to do a test run with few frames, use Trim or SelectEvery on /the original clip/.
  • Reducing the framecount (Trim/SelectEvery) and Crop'ping away parts of the movie will both reduce the AnalyzeLogo quality. I think you crop away too much. Maybe crop away 3/4 of the movie area... Since I feel we're running out of ideas: Try again with the inflated mask (see above) and the full clip (no Trimming/Cropping). Make sure you're delogo'ing does not inadvertedly use the old AnalyzeLogo output.
  • At the moment you should not need the DistanceFunction (I saw this somewhere in your scripts).
  • After running AnalyzeLogo /and/ after saving the output as ebmp, print out the "Info" of AnalyzeLogo output. The framecount of this clip is a hint on how many frame have actually been analyzed before the buffers of AnalyzeLogo ran full. Is it lower than the framecount of the original clip?
-- AMSS0815
AMSS0815 is offline   Reply With Quote
Old 14th April 2012, 17:30   #33  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Quote:
Originally Posted by AMSS0815 View Post
You wrote you saved a small clip to a separate file.[...]
Argh, sorry, I didn't read the script you posted.

So I suggest to cut away less (in space and time). I propose the following modified version of your script:
Code:
L=clip.Width/2    # [AMSS0815 modification!]  More reference area
T=0
R=0
B=-clip.Height/2  # [AMSS0815 modification!]  More reference area

# We crop the analyze clip and set a percentage for speed  
cropped     = clip.crop(L,T,R,B)
snipSize    = round( framecount( cropped ) / (framecount( cropped ) * (percent / 100.0) ))
AnalyzeClip     = ( percent != 100 ) ? cropped.SelectRangeEvery( snipSize, 1 ) : cropped
# ...........
# We provide the RGB24 *.bmp (C1 above) as the "Mask" argument for analysis,
# the corner of interest is cropped out
logo_mask   = imagesource(Mask,start=0,end=1)
logo_mask   = logo_mask.crop(L,T,R,B)
logo_mask   = logo_mask.ConvertToYV12(Matrix="PC.601")
logo_mask   = logo_mask.Grayscale  # [AMSS0815 modification!]  Remove spurious colors from cs conversion
logo_mask   = logo_mask.DistanceFunction.Levels(254-8,1,255-8,0,255,false)  # [AMSS0815 modification!]  Inflate 8 px
#logo_mask   = logo_mask.DistanceFunction(255/deblendfalloff).Greyscale  # [AMSS0815 modification!]  Not needed (me thinks)
# ...........
# We clean the analyze clip to improve results
#AnalyzeClip = (IsYV12(AnalyzeClip)) ? AnalyzeClip : AnalyzeClip.ConvertToYV12  # [AMSS0815 modification!]  RGB is probably better
AnalyzeClip = AnalyzeClip.ConvertToRGB24(Matrix="PC.601")  # [AMSS0815 modification!]
#AnalyzeClip = AnalyzeClip.TTempSmoothF(maxr=2,lthresh=256,cthresh=256,scthresh=255).ConvertToRGB24()  # [AMSS0815 modification!]  No! Not here
# Is it better here to use ConvertToRGB32() instead of ConvertToRGB24(), or leave it without any?
#
# ...........here we check if a resulting ebmp exists or if it has changed
# We perform the logo analysis
{
  AnalyzeClip.AnalyzeLogo(logo_mask)
  fc = FrameCount  # [AMSS0815 modification!]  Save now, print later
  # and save the resulting frame
  Trim( 0, -1 )
  ImageWriter( "AnalyzeResult", 0, 1, "ebmp" )
}
MessageClip(string(fc))  # [AMSS0815 modification!]  Print number of frames analyzed
Does the number printed here match the framecount of your input clip (with percent=100)?
Can you upload the resulting ebmp?
And of course the main question:
Code:
cropped = the clip from above !
ImageSource("AnalyzeResult%06d.ebmp",0,0)
AssumeFPS(cropped.FrameRate)
LogoColor = Crop(0,0,0,Height/2)
LogoAlpha = Crop(0,Height/2,0,0).ConvertToYV12(Matrix="PC.601")
cropped
ConvertToRGB24(Matrix="PC.601")
last.DeblendLogo(LogoColor,LogoAlpha)
What does this look like?

The logo in your picture A1 does not seem to have any opaque areas. If this is indeed the case, there is no need to use InpaintLogo (and no need to prepare RepairMasks).

Are B2 and D2 also frame from the movie --- did the camera focus on something very pink?

If this does not work, you will have to draw a mask for InpaintLogo (by hand) which marks the areas that exhibit this glass effect, and then use InpaintLogo to fix those areas. Sorry, but I have no further ideas.

-- AMSS0815
AMSS0815 is offline   Reply With Quote
Old 16th April 2012, 20:00   #34  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Hi AMSS0815,

I spent the whole weekend and monday's night for additional experiments (have more ideas) and practice upon your suggestions, so please don't consider my silence as a falling away. My last good-buy to this problem will be obvious for you as soon as possible
Quote:
Originally Posted by AMSS0815 View Post
You wrote you saved a small clip to a separate file. Try to avoid such steps, especially if they involve loosy compression. Always work with the original clip...
.............
Reducing the framecount (Trim/SelectEvery) will reduce the AnalyzeLogo quality.
.............
Does the number printed here match the framecount of your input clip (with percent=100)?
From the very beginning I've been processing the experimental clip (a 4-minutes cut out from the source) that keeps the original quality - no trimming, no compression. When experimenting, it's a rule for me to use the Lagarith lossless if encoding needed... The above-suggested FrameCount() shows the same number of frames as the input movie includes.

Quote:
Originally Posted by AMSS0815 View Post
Make sure you're delogo'ing does not inadvertedly use the old AnalyzeLogo output.
No problem here.

Quote:
Originally Posted by AMSS0815 View Post
Are B2 and D2 also frame from the movie --- did the camera focus on something very pink?
Here is the experimental clip: https://rapidshare.com/files/3942090...imentalClip.ts . The B2 and D2 are frames from the movie (see closer to the end of the clip).
Quote:
Originally Posted by AMSS0815 View Post
Can you upload the resulting ebmp?
And of course the main question:
Code:
cropped = the clip from above !
ImageSource("AnalyzeResult%06d.ebmp",0,0)
AssumeFPS(cropped.FrameRate)
LogoColor = Crop(0,0,0,Height/2)
LogoAlpha = Crop(0,Height/2,0,0).ConvertToYV12(Matrix="PC.601")
cropped
ConvertToRGB24(Matrix="PC.601")
last.DeblendLogo(LogoColor,LogoAlpha)
What does this look like?
Here is the ebmp (https://rapidshare.com/files/3729381...ult000000.ebmp) resulted from this script:
Code:
Movie = last	# 1280x720 YV12 BT709-5

DeblendFalloff=8
L=0 # Movie.Width/2    # [AMSS0815 modification!]  More reference area
T=0
R=0
B=0 # -Movie.Height/2  # [AMSS0815 modification!]  More reference area

# We provide the "Mask" argument for analysis, the corner of interest is cropped out
ImageSource("D:\Temp\Logo\LogoMask.bmp",start=0,end=1).crop(L,T,R,B)
Logo_mask   = last
Logo_mask   = Logo_mask.ConvertToYV12(Matrix="PC.601")
Logo_mask   = logo_mask.Grayscale  # [AMSS0815 modification!]  Remove spurious colors from cs conversion
Logo_mask   = logo_mask.DistanceFunction.Levels(254-DeblendFalloff,1,255-DeblendFalloff,0,255,false)  # [AMSS0815 modification!]  Inflate 8 px

cropped = Movie.crop(L,T,R,B)
AnalyzeClip = cropped.ConvertToRGB24(Matrix="PC.601")  # [AMSS0815 modification!]

try{                                # We check if a resulting ebmp exists or if it has changed
  ImageSource("D:\Temp\Logo\AnalyzeResult%06d.ebmp",0,0)
  (Interleave(AssumeFPS(Movie.FrameRate),AnalyzeClip.Trim(0,-2).AnalyzeLogo(Logo_mask)).FrameCount>-10)?last:last
}catch(dummy){
                                      # We perform the Logo analysis, the color and the alpha mask are returned
  AnalyzeClip.AnalyzeLogo(Logo_mask)
#  AnalyzeFrameCount = FrameCount          # [AMSS0815 modification!] Analyze returns the number of frames processed as frame count of the resulting clip
  Trim(0,-1)
  ImageWriter("D:\Temp\Logo\AnalyzeResult",0,1,"ebmp")  # Frame is written to hard disk
}
#MessageClip(string(AnalyzeFrameCount))  # [AMSS0815 modification!] Print number of frames analyzed

ImageSource("D:\Temp\Logo\AnalyzeResult000000.ebmp",0,0)
AssumeFPS(movie.FrameRate)
LogoColor = Crop(0,0,0,Height/2)
LogoAlpha = Crop(0,Height/2,0,0).ConvertToYV12(Matrix="PC.601")

cropped
ConvertToRGB24(Matrix="PC.601")
DeblendedClip = last.DeblendLogo(LogoColor,LogoAlpha)
Here is Alpha (A below) from the above ebmp, and the result of deblending (B below, comparing to B1) that partially includes the Alpha -- this effect is more visible instead of light background (C below) /is it a wrong estimated alpha mask?/.
A3> B3>
C3> D3>
The above D3 shows the final result when completing the code with the "step by Karel Suhajda" as you call it:
Code:
Movie.ConvertToRGB32.Layer(DeblendedClip.ConvertToRGB32.Mask(Logo_mask.ConvertToRGB32(Matrix="PC.601")))
ConvertToRGB24
Quote:
Originally Posted by AMSS0815 View Post
I cannot see dynamics though. Do you have the feeling that it changes from frame to frame, maybe in front of a bright background?
When deblending with previous settings (a highly-cropped clip analized), I have the feeling that aftershapes change their colors depending on a mix of surrounding colors, and a mix of dark colors is partially masked by a darker background, while be more visible instead of bright backgrounds. But uncropped frames as well as twice-cropped ones look as if AVSinpaint is focus-sensitive, I mean it may be not correct in analizing big areas and may cause mirror-effects on small areas (I do wish I'd be mistaken in this matter) when going far away from an artificial center (e.g. when a set of calculations start from and depend on a set of core measures, such as 720 width and 576 height, with further enlargement or shrinking from this core).

At this time I'm trying variable options to convert the colormatrix of my clip before feeding it to AVSinpaint. I feel it may help. Finally, if our efforts will not be productive, do you consider a two-stage deblending as a good variant instead of post-inpainting?

Thank you very much for your time.
Have a good, successful day!

Last edited by shark000X; 17th April 2012 at 02:02.
shark000X is offline   Reply With Quote
Old 21st April 2012, 03:12   #35  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Hi AMSS0815,

There is not much progress with my problem. I've tried all variants of colormatrix transform (PC<->TV between 601, 709, 240 and FCC standards) that my source could possibly undergone before the final encoding. Some interesting results occurred, but they are hard to implement.

The shapes of logo look better for deblending after TV.709->PC.FCC transform (yeah, my source has a European nature for sure, so it was more intuitive than logical idea to try the American FCC standard). Moreover, TV.240->PC.601 is the best variant, but still not enough for illuminated areas especially.

The first conclusion here - the levels want to be restricted to TV-range before colormatrix changing.

Further, let us analyze the colormatrix tables (the right one created for comfortable searching of dependences):
Keeping in mind the results, I see they are better when increasing the Red coefficient up to 41% (the 0.087 differential for both 709->FCC and 240->601), while decreasing the Green and increasing the Blue coefficients. The tendency is obvious, but the Blue doesn't like a much difference from the previous state (53% loose against 31%).

The second conclusion here - the color balance is not suitable for the AnalyzeLogo.

Proceeding from the above conclusions I tried (assuming it is useless) to prepare the movie under AutoGain and AutoLevels (simultaneously and not) -- they certainly helped to make the logo more solid (it's a kind of goodbye to further deblending). I don't know any other way to find the good color balance for AnalyzeLogo, except the hundreds or thousands iterations for manual picking-up-and-down. Uuuff, it's driving me crazy sometime, but I continue experiments and looking for new reasonable opportunities.

Since the above situation arrived, some new questions appeared:
10) Is there any additional convertion activated inside the AVSinpaint? (e.g. if YV12 or YUY2 inputed to AVSinpaint but further converted for inside RGB processing)
11) Does AVSinpaint include any specific restrictions as to color balance? If yes, how can I learn them and/or improve?

I am not going to annoy like the logo does, but AMSS0815 please tell me at least if you can help me or not to deblend it.
Thank you. Good bye.

Last edited by shark000X; 22nd April 2012 at 23:15. Reason: the name is changed to pseudonym
shark000X is offline   Reply With Quote
Old 21st April 2012, 12:59   #36  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi shark000X,

I downloaded your ExperimentalClip and successfully reproduced your glass-like effect. I think you're doing everything allright, yet the problem persists. So my conclusion is that you cannot remove this logo with my tools. I observed that not only the borders of this logo, but also the interior is badly deblended: It is still brighter that its surrounding when it is in front of a bright background. Maybe the logo was added in some "nonlinear" way to the video or something else "nonlinear" happened with it while being processed further before it was delivered to you. (Nonlinear refers to some transformation that is incompatible with my linear model, see documentation of plugin). I tried to fix this with InpaintLogo, even to the point of inpainting the whole logo region, but since the logo is so big, the result was horribly ugly.

(I only considered 4 minutes of your clip since I had to transform it to huffyuv, but I'm sure the results would be the same if I took the whole clip).

Nevertheless I can answer your questions as follows:
Quote:
But uncropped frames as well as twice-cropped ones look as if AVSinpaint is focus-sensitive, I mean it may be not correct in analizing big areas and may cause mirror-effects on small areas (I do wish I'd be mistaken in this matter) when going far away from an artificial center
I don't really understand this comment. The main functionality of AnalyzeLogo is the detection of the alpha mask of the logo. For this it computes the sample covariance of the logo pixels and compares it with the sample covariance of surrounding pixels (cf. doc). The underlying assumption is that the covariances would be the same without the logo and the covariances with logo are reduced by the alpha value of the logo (high opacity means low variance). This obviously fails if the variances differ in space, that's why non-picture parts of the movie have to be removed or masked before AnalyzeLogo is used. But I don't think your clip suffers from such a spacial variance difference. Also, I tested AnalyzeLogo with different croppings and it didn't help --- well, it didn't help me, but maybe you're lucky here.
Quote:
Finally, if our efforts will not be productive, do you consider a two-stage deblending as a good variant instead of post-inpainting?
Two-stage means Analyze+Deblend, then Analyze+Deblend the result? This is an interesting idea. I just tried it and the second mask (result of second AnalyzeLogo invocation) shows just white noise where the logo is. The final result didn't really look better. (Theoretically, I would expect the second invocation of AnalyzeLogo to produce an all-black mask. I don't know where the noise comes from.)
Quote:
10) Is there any additional convertion activated inside the AVSinpaint? (e.g. if YV12 or YUY2 inputed to AVSinpaint but further converted for inside RGB processing)
No. At some points averages of pixel color values are required. If I remember correctly, InpaintLogo has to create a common structuring tensor from gradients of red/green/blue color planes. This tensor is a convex combination of the three tensors of each plane, <NOT TRUE>with coefficients taken from some well known RGB-->YUV conversion matrix</NOT TRUE>. AnalyzeLogo has to compute a common alpha channel from each color plane's alpha channel, this is also a convex combination, and the coefficients can be controlled by the *Weight parameters. But I don't see a problem in all these conversations.
Quote:
11) Does AVSinpaint include any specific restrictions as to color balance? If yes, how can I learn them and/or improve?
Err, somehow no. AnalyzeLogo assumes that the logo's alpha mask is the same for each channel (r,g,b or y,u,v). If you rescale one channel only, this assumption is no longer valid and AnalyzeLogo produces some average of the different alpha channels. While I'm not sure what "color balance" is, I don't think there are any more restrictions.

btw: I also tried to Analyze+Deblend a Grayscale version of your clip, and each RGB channel separately. All four tests failed, i.e., showed the glass-like effect.

Sorry, I'm out of ideas. As I said above, it seems AVSInpaint isn't suitable for this kind of logo.

Although my name is part of the AVSInpaint code/copyright-notes/documentation and hence public, I would prefer you use my pseudonym (AMSS0815) when you address me here. Thanks.

-- AMSS0815

Last edited by AMSS0815; 23rd April 2012 at 22:31. Reason: I stand corrected
AMSS0815 is offline   Reply With Quote
Old 22nd April 2012, 15:41   #37  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Hi AMSS0815,

Quote:
Originally Posted by AMSS0815 View Post
Two-stage means Analyze+Deblend, then Analyze+Deblend the result? This is an interesting idea. I just tried it and the second mask (result of second AnalyzeLogo invocation) shows just white noise where the logo is.
Yes, you understand me right. And perhaps the second stage of Analyze+Deblend needs some kind of pre- and/or post-processing with denoisers, but I'm going to try the denoising later if intrusion-free methods of simple deblending will be exhausted.

Quote:
Originally Posted by AMSS0815 View Post
I also tried to Analyze+Deblend a Grayscale version of your clip, and each RGB channel separately. All four tests failed, i.e., showed the glass-like effect.
Me too. Sorry that have not mentioned it earlier, I could prevent you from this unnecessary action if only knew you were going for some experiments. And please have my excuse for neglecting the pseudonym, it was done automatically (sometimes it is much faster to write a wellknown human name than to copypaste a nickname consisting of character set not easy to remember).

Quote:
Originally Posted by AMSS0815 View Post
...a common structuring tensor from gradients of red/green/blue color planes. This tensor is a convex combination of the three tensors of each plane, with coefficients taken from some well known RGB-->YUV conversion matrix. AnalyzeLogo has to compute a common alpha channel from each color plane's alpha channel, this is also a convex combination, and the coefficients can be controlled by the *Weight parameters.
Aha. It may be the reason why we need to make PC.601 before analyzing a clip, I presume the three-spined tensor is calculated according to the following matrix resulting in some restrictions:
I wonder would it be helpful to clean the restrictions if the AnalyzeLogo translated colorspaces using another method, e.g. as for Y'UV420p to RGB (see http://en.wikipedia.org/wiki/YUV ):
Code:
size.total = size.width * size.height;
y = yuv[position.y * size.width + position.x];
u = yuv[(position.y / 2) * (size.width / 2) + (position.x / 2) + size.total];
v = yuv[(position.y / 2) * (size.width / 2) + (position.x / 2) + size.total + (size.total / 4)];
rgb = Y'UV444toRGB888(y, u, v);
The Y', U and V components are computed separately in sequential blocks, the above diagram shows (corresponding Y', U and V values are shown using the same color). A Y' value is stored for every pixel, followed by a U value for each 2x2 square block of pixels, and finally a V value for each 2x2 block. Reading line-by-line as a byte stream, the Y' block would be found at position 0, the U block at position x*y (6*4 = 24 in this example) and the V block at position x*y + (x*y)/4 (here, 6*4 + (6*4)/4 = 30). Moreover, this method let us control the DeviationWeights separately for each channel, as I hope.

........
Errr, actually I've started this post yesterday after your reply, but the incorrect color balance of the movie was drilling my mind all the time, so I interrupted and tried the Photoshop to widely analize some frames of the source. Now it seems the movie is mainly out of gamut (Photoshop>> Select / Range / Out of Gamut). When certain colors cannot be expressed within a particular color model, those colors are said to be out of gamut. As I think, the out of gamut colors may lead the AnalizeLogo to a wrong color estimation and big mistakes when creating the color map. And, following back to
Quote:
Originally Posted by shark000X View Post
When deblending with previous settings (a highly-cropped clip analized), I have the feeling that aftershapes change their colors depending on a mix of surrounding colors, and a mix of dark colors is partially masked by a darker background, while be more visible instead of bright backgrounds. But uncropped frames as well as twice-cropped ones look as if AVSinpaint is focus-sensitive, I mean it may be not correct in analizing big areas and may cause mirror-effects on small areas (I do wish I'd be mistaken in this matter) when going far away from an artificial center
the bigger the analized area, the more volume of extragamut colors is estimated turning the AnalizeLogo into a blind kitten.

As I knew from the Photoshop Bible, to handle the out of gamut colors we need to change the hue and saturation. Heh, it is not so complicated when editing a separate image, but some kind of Hue-Saturation-Brightness model is needed to enough edit the thousands frames and preserve a good balance. Fortunately, after some non-productive experiments, I found two threads with great ideas as to this matter ( http://forum.doom9.org/showthread.ph...81#post1405481 , EDIT: http://forum.doom9.org/showthread.php?t=154731 ), and now going to try the functions...

Would the end-point be successful or not, thank you AMSS0815 for your participation, efforts and the great tool. I'm going to post the results for other users here, if you don't mind, to help avoid some bothering questions in future. Anyway, if you'll have some time, the further comments are much appreciated since you are the only guru here for last years who explains the problems of logo-removing.

Good bye

Last edited by shark000X; 23rd April 2012 at 09:45. Reason: a wrong link corrected
shark000X is offline   Reply With Quote
Old 23rd April 2012, 22:51   #38  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Quote:
Originally Posted by shark000X View Post
Quote:
Originally Posted by AMSS0815
...a common structuring tensor from gradients of red/green/blue color planes. This tensor is a convex combination of the three tensors of each plane, with coefficients taken from some well known RGB-->YUV conversion matrix. AnalyzeLogo has to compute a common alpha channel from each color plane's alpha channel, this is also a convex combination, and the coefficients can be controlled by the *Weight parameters.
Aha. It may be the reason why we need to make PC.601 before analyzing a clip, I presume the three-spined tensor is calculated according to the following matrix resulting in some restrictions:
[.....]
No. I was wrong about the RGB<-->YUV conversion matrix. It is never directly used in my plug in. If InpaintLogo is applied to a RGB clip, the convex combination is simply the average of all 3 (or 4 for RGBA) channels. For YUV clips, the ChromaWeight parameter controls the coefficients. Coefficients for AnalyzeLogo's common alpha mask value are controlled by the estimated alpha values of each channel and a subsampling factor. There is also no RGB<-->YUV matrix involved here. (I learned that by reading my own docs).
Quote:
Now it seems the movie is mainly out of gamut (Photoshop>> Select / Range / Out of Gamut). When certain colors cannot be expressed within a particular color model, those colors are said to be out of gamut. As I think, the out of gamut colors may lead the AnalizeLogo to a wrong color estimation and big mistakes when creating the color map.
This is out of my expertise. If this means that the color values of your video were once rescaled and clipped (at least in audio processing this is called clipping, if they exceed the highest possible value), then yes, this is a kind of distortion that would violate AnalyzeLogo's assumptions about the logo and hence create a broken mask.
Quote:
I'm going to post the results for other users here, if you don't mind, to help avoid some bothering questions in future.
Of course. I don't see myself as the owner of this thread anyway.
-- AMSS0815
AMSS0815 is offline   Reply With Quote
Old 25th April 2012, 19:24   #39  |  Link
shark000X
Real Harper's Mockingbird
 
Join Date: Mar 2012
Posts: 14
Eureka!

Hi AMSS0815,

I'm at complete understanding where the problem grows from.

Quote:
Originally Posted by AMSS0815 View Post
I was wrong about the RGB<-->YUV conversion matrix. It is never directly used in my plug in... For YUV clips, the ChromaWeight parameter controls the coefficients. Coefficients for AnalyzeLogo's common alpha mask value are controlled by the estimated alpha values of each channel and a subsampling factor. There is also no RGB<-->YUV matrix involved here. (I learned that by reading my own docs).
.................
If ... the color values of your video were once rescaled and clipped ..., then yes, this is a kind of distortion that would violate AnalyzeLogo's assumptions about the logo and hence create a broken mask.
Yeh, now I see a matrix itself cause no problem here, but the AnalizeLogo operates the inner-restricted 128 range for Chroma -- the same way as a simple YUV->RGB convertion does (Ymax=255, Umax=128, Vmax=128) -- resulting all the U and V values out of 128 range to be clipped by the AnalizeLogo itself, even if they haven't been distorted while a source movie undergone editing and encoding. As a practical example, there is a kind of picture how the AnalizeLogo could do (if not restricted to 128 range) but does not recognize the logo EDITed>(the non-black parts show the clipped RGB-illegal colors which lead to the violate assumptions):
A4> B4>
C4> D4>
The A4 image is correspondent to A1, B1, A2 sourced from the same frame, and B4 corresponds to B2, D2. The tendency is obvious: the logo remains closer to untouched when itself containing illegal colors (see B4<->B2), and it's better deblended when free of illegal colors (A4<->A2) but still remains visible because surrounded by out-of-gamut areas or because of the violate assumptions caused by the rest of frames (there are a lot of them like C4, D4). These images are taken after running the ShowBadRGB function, thanx to Gavino (http://forum.doom9.org/showthread.ph...32#post1403732).<EDITed

It is worthy to be mentioned that the RGB space has been preliminary intended for analog devices, so nowadays it's an archaic way to produce an original material in the field of RGB which casually exists for rendering and filtering. Modern devices use the YUV space to produce video clips that often include the U and V ranged over 128 limits (so-called "out of gamut"). This means the problem is going to be typical for the majority of sources originated from the YUV space, not only mine.

At this moment I see two ways to throw this problem globally away:

I. If the appropriate AVSinpaint algorythm allows, to expand the analyze range to 255 for U and V to be calculated without clipping. Then the Alpha and ColorMap results have to be furhter processed and saved in the YUV colorspace (RGB processing and further conversion to YUV is not helpful of course). Here may be reasonable to process and save the U and V channels separately keeping luma the same for both.

II. If the above-mentioned algorythm doesn't allow and there is no other one that could be based on 255 range, to implement the independent U and V limitation technique (http://downloads.bbc.co.uk/rd/pubs/reports/1987-22.pdf). The idea intends to avoid clipping and to keep the out-of-range U and V by means of Uout/Uin and Vout/Vin ratios. There are three variants (algorythms) but the simpliest one might be enough for logo-removing.

AMSS0815, would you be so kind to modernize the AVSinpaint? You have the needed knowledge, practical experience and an alfa-beta tester in my person

Looking for the productive cooperation, thanx.
Have a nice day.
Good bye.

Last edited by shark000X; 27th April 2012 at 10:17. Reason: the ill-fitting images and further assumptions edited
shark000X is offline   Reply With Quote
Old 26th April 2012, 09:45   #40  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
OK, I just skimmed your response and I hope I understand you correctly.
Quote:
Originally Posted by shark000X View Post
but the AnalizeLogo operates the inner-restricted 128 range for Chroma -- the same way as a simple YUV->RGB convertion does (Ymax=255, Umax=128, Vmax=128) -- resulting all the U and V values out of 128 range to be clipped by the AnalizeLogo itself
Short response: No, and: a simple YUV->RGB conversion clips U and V values?? Maybe there is some shifting going on, like [0,255]-->[-128,127] or similar, but I cannot imagine that YUV wastes halve of its color range.

Anyway, up to programming bugs (which might always exist), AnalyzeLogo does not clip any color range. I suspect that your analysis refers to this part of the docs:
Quote:
To prevent overflow of the sum of squares, all pixel values are reduced by 128 prior to computation.
This means that all color channels that get analyzed (R,G,B, maybe A, or Y,U,V) get shifted [0,255]-->[-128,127]. The reason for this is that AnalyzeLogo sums up the squares of the channels pixel values until the end of the movie clip or until the 32-bit buffer runs full (a 32-bit integer for each pixel and each channel). This shift keeps the squares a bit smaller and allows more frames to be summed up before the buffer runs full. No information is lost here, no clipping occurs. And the shift is reversed before the color part of the logo is returned to the user.

I cannot test this right now, only at weekend, but maybe you can: Apply AnalyzeLogo+Deblend to YourClip.Grayscale.Levels(0,1,255,0,127). This clip should have all pixel values in permitted ranges, and I expect you to observe the same (glass-like) problem. On the other hand, if this works well (and you have thus solved your problem at least for a Grayscale'd version of your clip), you have a point and I will have a closer look at my code.

-- AMSS0815
AMSS0815 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:46.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.