View Single Post
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