vcmohan
15th June 2005, 04:13
I have made a little more progress on my recoloring project. Here are my script and results. I would appreciate critical comments and suggestions. As mentioned in my earlier post my scheme depends upon mask creation to separate out objects. (it can be grey values, edges, or lines drawn or a combination of all. Linear variation with frame numbers of colordrops and other functions ease in scripting for moving objects. Below is script and results.
loadPlugin (".....\colorit.dll")
loadPlugin (".......\Grid.dll")
loadPlugin(".......\EffectsMany.dll")
#----------------------------------------
# original scene creation A beach still photo is read and looped 50 times.
#on this two balloons hop.
ImageReader ("....../Originalbeach.jpg"...)
loop(0,50)
#As Image reader in my version is buggy and I can not use trim for getting just the first frame and I already have output of this in another project, I used following statement
#AVISource("F:\TransVideo.avi").trim(0,50)
#EffectBalloon is a function in my EffectsMany plugin (warpenterprises page)
#first balloon makes 3 (parabolic) hops between frames 1 to 41
EffectBalloon(last,1,41, color=$ff7f,opacity=90,light="west",refl=5, nhops=3)
#Second balloon makes single hop appears frame 6 to 46
EffectBalloon(last,6,46, color=$7f7f00,opacity=80,light="nw",refl=2)
YUY=converttoYUY2()
# greyscale image is input to recolor process
a=GreyScale(yuy)
# colorit plugin has Gaussian blur, morpher,draw lines, mask maker, EdgeMarker,color shift, color stretch, color filling for areas, lines, and points using a mask reference, cross fill and inlay using a mask and drawn lines. Some of them have test facility for parameter value selection.
Grid plugin is used to read off coordinates for input.
# following script is for recoloring. While fore some parts I used very near to original colors, I deliberately deviated from them in several other cases including balloons. About 32 lines of script was required.
g=GaussBlur(a,false,1)
b=blankclip(a,color=0)
# colors used for some
bal1=$7f7f
bal2=$4f5fdf
sand=$dbcba0
starfish=$966d50
# curved lines and straight lines
cl=drawlines(b,0,50,0,220,40,240,120,240,150,230,180,210,210,210,260,140,280,110,300,80,350,90,500,94,560,100,650,80,719,80,true,true)
sl=drawlines(b,0,50,700,200,400,278,curve=false,white=true)
sr=drawlines(sl,0,50,400,400,600,360,650,380,719,380,curve=false,white=true)
## use lines "above" for stones and "below" for sand and shells. use white
mm=maskmaker(a,0,50,"c1", thresh=1,ethresh=100)
#for stones within surf region
ii=inlay(a,mm,cl,0,50,"above", color=$1f3253)
#for surf
ii=inlay(ii,mm,cl,0,50,"above", color=$ffffff, mwhite=false)
#for sand
iii=inlay(ii,mm,cl,0,50,"below", color=sand, mwhite=false)
my=maskmaker(a,0,50,"c1", thresh=130,ethresh=220)
shl=drawlines(b,0,50,0,300,719,300,curve=false)
iii2=inlay(iii,my,shl,0,50,"below", color=starfish,mwhite=false)
#shells
iii3=inlay(iii2,mm,sr,0,50,"vint",mwhite=true)
ls1=drawlines(b,0,50,100,300,100,380,0,430,curve=false,white=true)
ls2=inlay(iii3,mm,ls1,0,50,"left",color=$d66d50,mwhite=true)
## for whitish shells
ms=maskmaker(a,0,50,"c1", thresh=200,ethresh=250)
shln=drawlines(b,0,50,0,300,719,400, curve=false)
ls3=inlay(ls2,ms,shln,0,50,"below",color=$fdf1ed,mwhite=true)
## for right side greenish shell
emp2=EMarker(g,0,50,"es",thresh=38)
# morpher for correcting mask. Default option "close" is used
mmp2=morpher(emp2,0,50)
cmp2=colordrops(ls3,emp2,0,50,630,350,$7f7f30)
#for right side lower blue spoted shell
bmm=maskmaker(g,0,50,"c1",thresh=148,ethresh=190)
bln=drawlines(b,0,50,515,422,555,422,curve=false)
bin=inlay(cmp2,bmm,bln,0,50,"below",color=$4545cc,mwhite=true)
#balloon1 and balloon 2 mask
mp1=EMarker(g,0,50,"es",6)
#balloon1 tracking and coloring
cd=colordrops(bin,mp1,1,8,60,370,bal1,160,10,bal1,vary=true)
cd1=colordrops(cd,mp1,9,15,180,20,bal1,260,400,bal1,vary=true)
cd1=colordrops(cd1,mp1,16,21,280,250,bal1,350,25,bal1,vary=true)
cd1=colordrops(cd1,mp1,22,28,370,20,bal1,460,350,bal1,vary=true)
cd1=colordrops(cd1,mp1,29,35,470,300,bal1,550,10,bal1,vary=true)
cd1=colordrops(cd1,mp1,36,41,570,10,bal1,650,300,bal1,vary=true)
#balloon2 tracking and coloring
cd2=colordrops(cd1,mp1,6,26,60,400,bal2,360,10,bal2,vary=true)
cd2=colordrops(cd2,mp1,27,46,370,10,bal2,650,340,bal2,vary=true)
# display for this post
selectEven(cd2)
selectodd()
reduceby2()
# the Grid function is a great help for specifying coordinates.
#Grid(cd2,0,50, color=$888888)
Displays:
Original Beach image
http://img143.echo.cx/img143/2570/originalbeach06kl.jpg (http://www.imageshack.us)
Greyscale image of beach
http://img143.echo.cx/img143/7892/greyscalebeach09oa.jpg (http://www.imageshack.us)
Recolored beach
http://img143.echo.cx/img143/2681/recoloredbeach08tg.jpg (http://www.imageshack.us)
Thumbnails of recolored images of balloons hopping
1
http://img143.echo.cx/img143/5581/recoloredbeachballoons19tk.th.jpg (http://img143.echo.cx/my.php?image=recoloredbeachballoons19tk.jpg)
2
http://img153.echo.cx/img153/6652/recoloredbeachballoons24vf.th.jpg (http://img153.echo.cx/my.php?image=recoloredbeachballoons24vf.jpg)
3
http://img153.echo.cx/img153/1986/recoloredbeachballoons30dt.th.jpg (http://img153.echo.cx/my.php?image=recoloredbeachballoons30dt.jpg)
4
http://img153.echo.cx/img153/6981/recoloredbeachballoons43yk.th.jpg (http://img153.echo.cx/my.php?image=recoloredbeachballoons43yk.jpg)
5
http://img148.echo.cx/img148/1420/recoloredbeachballoons53yv.th.jpg (http://img148.echo.cx/my.php?image=recoloredbeachballoons53yv.jpg)
6
http://img148.echo.cx/img148/3064/recoloredbeachballoons67eh.th.jpg (http://img148.echo.cx/my.php?image=recoloredbeachballoons67eh.jpg)
7
http://img148.echo.cx/img148/7931/recoloredbeachballoons70hb.th.jpg (http://img148.echo.cx/my.php?image=recoloredbeachballoons70hb.jpg)
8
http://img299.echo.cx/img299/3724/recoloredbeachballoons84rk.th.jpg (http://img299.echo.cx/my.php?image=recoloredbeachballoons84rk.jpg)
9
http://img299.echo.cx/img299/2172/recoloredbeachballoons96ri.th.jpg (http://img299.echo.cx/my.php?image=recoloredbeachballoons96ri.jpg)
10
http://img299.echo.cx/img299/3647/recoloredbeachballoons108yv.th.jpg (http://img299.echo.cx/my.php?image=recoloredbeachballoons108yv.jpg)
11
http://img299.echo.cx/img299/1269/recoloredbeachballoons122oc.th.jpg (http://img299.echo.cx/my.php?image=recoloredbeachballoons122oc.jpg)
my next attempt will be to recolor scene with people faces, dress and background.
vcmohan
5th July 2005, 03:24
I have attempted to color a greyscale image derived from an color photo of a birthday party held in a open lawn. There are a number of children and adults, balloons cake etc along with other items.
As can be seen I have been to a large extent successful. I find that a lot of patience and time is needed. May be a number of persons working parallel on different scenes can create a colored movie out of a black and white original.
I use grey scale values and edge detection schemes to demarcate areas. I found that both sobel, prewit even with laplace combination do not give usable demarcations for this purpose. This may be due to almost insignificant level changes at certain places. This forces manual intervention by way of extending demarcation lines.
I have also some difficulty in treating the edge itself. It remains and sometimes seen. Grey scale value itself is a better demarcator than edge detection in my experience.
Below are the images.
Grey Scale
http://img161.imageshack.us/img161/9071/birthday10hi.jpg (http://www.imageshack.us)
colored
http://img161.imageshack.us/img161/1405/birthday06lp.jpg (http://www.imageshack.us)
original
http://img161.imageshack.us/img161/3509/birthday21ar.jpg (http://www.imageshack.us)
loadPlugin ("E:\TransPlugins\bin\Colorit\Release\colorit.dll")
loadPlugin ("E:\TransPlugins\bin\Grid\Release\Grid.dll")
#----------------------------------------
imagereader("E:\TransPlugins\ch6.jpg",0,1,25,false)
reduceby2().crop(0,0,720,480)
YUY=converttoYUY2()
loop(yuy,100,0,0)
tr=trim(0,99)
blonde=$6d401d
face1=$e79c81
syrup=$f08080
hair=$f0507
#balloons
red=$9f2222
blue=$22339f
green=$229f22
yellow=$9f9f22
purple=$9f119f
a=GreyScale(tr)
g=GaussBlur(a,false,1)
b=blankclip(a,color=0)
#for lawn and plants
lawn=$a6b95e
plant=$9fb94e
mlawn=maskmaker(g,0,50,type="c1",gyt=118,et=183,rx=50,by=190,xcol=false)
cdlawn=colordrops(a,mlawn,0,50,10,100,lawn)
mlawn=maskmaker(g,0,50,type="c1",gyt=118,et=183,lx=200,rx=330,by=50,xcol=false)
mlawn=drawlines(mlawn,0,50,210,0,210,50)
cdlawn=colordrops(cdlawn,mlawn,0,50,205,40,lawn,250,30,lawn,315,30,lawn)
mlawn=maskmaker(g,0,50,type="c1",gyt=118,et=183,lx=500,by=150,xcol=false)
cdlawn=colordrops(cdlawn,mlawn,0,50,650,50,lawn,580,50,lawn)
elawn=EMarker(g,1,50,"es",gyt=43,lx=496,ty=70,by=180,xcol=false)
emlawn=drawlines(elawn,0,50,510,100,560,150)
cdlawn2=colordrops(cdlawn,emlawn,1,50,540,110,lawn,700,150,lawn)
#return(grid(cdlawn2,0,50,color=$7f3f00))
#black hair
mmhair1=maskmaker(g,2,50,"c1",gyt=21, et=45,rx=50,ty=350,xcol=false)
cdhair1=colordrops(cdlawn2,mmhair1,2,50,10,400,hair)
mmhair2=maskmaker(cdlawn2,2,50,"c1",gyt=21, et=45,lx=270,rx=600,by=350)
cdhair=colordrops(cdhair1,mmhair2,2,50,300,35,hair,550,250,hair,400,200,hair,455,10,hair,350,100,hair,240,2,hair)
mmtunic=maskmaker(cdhair,2,50,"c1",gyt=15, et=45,lx=205,rx=275,ty=35,by=260)
cdtunic=colordrops(cdhair,mmtunic,2,50,250,200,blue,265,80,blue,250,90,blue,215,45,blue)
#return(grid(cdtunic,0,50,color=$7f3f00))
#blonde
mmblnd=maskmaker(g,3,50,"c1",gyt=45,et=90,lx=600,ty=200,xcol=false)
lblnd=drawlines(mmblnd,3,50,630,250,610,260,610,280)
cdblnde=colordrops(cdhair,lblnd,3,50,660,250,blonde)
mgirl=maskmaker(cdblnde,3,50,"c1", gyt=95,et=195,lx=610,ty=250)
cdgirl=colordrops(cdblnde,mgirl,3,50,620,400,$f000a)
mgirl2=maskmaker(cdgirl,3,50,"c1",gyt=135,et=185,lx=610,ty=250)
cdgirl2=colordrops(cdgirl,mgirl2,3,50,640,430,blue)
mgirl3=maskmaker(cdgirl2,3,50,"c1", gyt=95,et=195,lx=610,ty=250)
dgirl3=drawlines(mgirl3,3,50,627,470,632,437)
cdblnd=colordrops(cdgirl2,dgirl3,3,50,700,400,face1,710,450,blue,715,450,blue,710,430,face1,690,300,blonde)
# maya?
#mm=maskmaker(cdhair1,3,50,"c1", gyt=20,et=50,test=true,ft=120,fet=150,rx=50,ty=350)
emaya=emarker(cdhair1,3,50,"e2",gyt=30,lt=2,rx=60,ty=350)
dmaya=drawlines(emaya,3,50,43,390,50,410,50,440,22,452,20,470,10,475)
cdmaya=colordrops(cdblnd,dmaya,3,50,40,420,face1)
#return(showpixelvalues(cdhair,500,100,bright=2,dim=0,threshold=1,showArea=true))
#return(grid(cdmaya,0,50,color=$7f3f00))
#syrup bowl and cake top
mm=maskmaker(g,4,50,"c1", gyt=180,et=235,test=true,ft=230,fet=235,lx=140,rx=310,ty=260,by=370,xcol=false)
mmcake=maskmaker(g,4,50,"c1",gyt=75,et=120,lx=140,rx=310,ty=260,by=370,xcol=false)
drcake=drawlines(b,4,50,260,300,220,265,145,275,185,315,260,300)
cdsyrp=colordrops(cdmaya,mmcake,4,50,280,320,syrup,155,320,purple)
incake=inlay(cdsyrp,mmcake,drcake,4,50,"hint",purple)
mcake=maskmaker(g,4,50,"c1", gyt=180,et=235,lx=140,rx=270,ty=280,by=350,xcol=false)
cdcake=colordrops(incake,mcake,4,50,200,320,$1f0405,st=-130)
mmsyrp2=maskmaker(g,4,50,"c1",gyt=45,et=90,lx=220,rx=310,ty=300,by=370,xcol=false)
cdsyrp2=colordrops(cdcake,mmsyrp2,4,50,260,360,syrup)
#wall
mmwall=maskmaker(g,4,50,"c1",gyt=150,et=195,lx=520,rx=580,by=40,xcol=false)
cdwall=colordrops(cdsyrp2,mmwall,4,50,560,10,$770000)
#return(grid(cdwall,0,50,color=$7f3f00))
#mm=maskmaker(cdsyrp2,5,50,"c1", gyt=50,et=150,test=true,ft=150,fet=250,lx=610,ty=250)
# girl red top
emredtop=EMarker(g,4,50,"es", gyt=19,lx=400,rx=480,ty=20,by=65,xcol=false)
cdredtop=colordrops(cdwall,emredtop,4,50,450,50,$9f4433)
#return(grid(mm,0,50,color=$7f3f00))
#plant and kshirt
mks=maskmaker(cdhair,5,50,"c1",gyt=121,et=161,lx=348,ty=60,by=230,rx=580)
cream=$dac07f
blue=$55668f
mks1=drawlines(b,5,50,450,60,570,150,580,210)
mks2=drawlines(mks1,5,50,350,60,350,210,440,210)
kps=inlay(cdredtop,mks,mks2,5,50,"hint",color=blue)
#embal=emarker(cdlawn,5,50,"ep",gyt=1,lt=1,test=true,ft=50,fl=1,lx=14,rx=235,by=272)
embal=emarker(cdhair,5,50,"ep",gyt=22,lx=14,rx=235,by=272)
drbal=drawlines(embal,5,50,230,95,215,115,236,135)
cdbal=colordrops(kps,drbal,5,50,50,100,red,45,150,green,30,30,purple)
#stackhorizontal(embal,g)
#return(pallet(b,10,30))
#mm=maskmaker(cdbal,5,50,"c1", gyt=50,et=150,test=true,ft=150,fet=250,lx=410,ty=250)
#return(grid(mm,0,50,color=$7f3f00))
# other faces, left over etc
mtlady=maskmaker(g,6,50,"c1",gyt=78,et=150,lx=210,rx=246,by=62)
cdtlady=colordrops(cdbal,mtlady,6,50,220,30,face1)
mtbikin=maskmaker(cdhair,6,50,"c1", gyt=52,et=150,lx=260,rx=310,ty=40,by=90)
cdbikin=colordrops(cdtlady,mtbikin,6,50,290,70,face1)
embik=emarker(cdhair,6,50,"esl",gyt=68,lt=1,lx=270,rx=330,ty=160,by=210)
drbik=drawlines(b,6,50,270,190,310,210,330,185)
rbik=inlay(cdbikin,embik,drbik,6,50,"above",color=blue,x=270,y=160,w=60,h=50)
gbik=inlay(rbik,embik,drbik,6,50,"above",color=blue,mwhite=false,x=270,y=160,w=60,h=50)
#metc=maskmaker(gbik,6,30,"c1", gyt=10,et=45,test=true,ft=130,fet=175,lx=155,rx=600,by=416)
metc=maskmaker(gbik,6,50,"c1", gyt=30,et=65,lx=210,rx=420,ty=36,by=260)
detc=drawlines(metc,6,50,330,190,330,210,330,220,355,210,265,160,270,162,290,140,300,142,260,90,270,100,265,130,280,130,330,210,370,210,line="diff")
cdetc=colordrops(gbik,detc,6,50,250,150,blue,250,200,blue,350,150,face1,335,157,face1,380,140,face1,260,140,face1,280,150,face1,280,110,blue,300,110,hair,300,230,face1,380,210,hair,400,230,hair,400,240,face1,280,220,face1)
#left over kshirt
mleft=maskmaker(cdetc,6,50,"c1", gyt=95,et=120,lx=350,rx=580,ty=60,by=230)
dleft=drawlines(b,6,50,350,80,440,60,580,175)
ileft=inlay(cdetc,mleft,dleft,6,50,"below",color=cream)
#chris body
#emetc=emarker(ileft,7,50,"epl", gyt=1,lt=2,test=true,ft=100,fl=2,lx=250,ty=200,rx=500,by=320)
emetc=emarker(ileft,7,50,"epl", gyt=52,lt=2,lx=250,ty=200,rx=500,by=320)
detc=drawlines(emetc,7,50,420,260,445,255,250,290,280,295,363,312,430,205,line="diff")
cdetc=colordrops(ileft,detc,7,50,400,300,face1,269,271,face1)
#stackvertical(emetc,ileft)
#return(grid(cdetc,0,50,color=$7f3f00))
#andrea
mand=maskmaker(cdetc,8,50,"c1", gyt=110,et=160,lx=470,ty=230,rx=582,by=440)
#mand=maskmaker(cdetc,8,50,"c1", gyt=50,et=100,test=true,ft=150,fet=200,lx=470,ty=230,rx=582,by=440)
drand=drawlines(mand,8,50,488,340,505,320,550,405,540,425,520,350,550,345,line = "diff")
cdand=colordrops(cdetc,drand,8,50,480,350,face1,515,350,face1,495,250,face1,500,280,face1,550,350,face1,530,340,face1,520,350,face1,500,370,purple)
mand2=maskmaker(cdand,8,50,"c1", gyt=150,et=170,lx=470,ty=230,rx=582,by=440)
#mand2=maskmaker(cdand,8,50,"c3", gyt=92,et=147,rt=128,ert=128,bt=128,ebt=128,lx=425,ty=210,rx=585,by=430)
drand2=drawlines(mand2,8,50,425,360,590,450,560,430,600,350)
cdand2=colordrops(cdand,drand2,8,50,570,380,face1,493,245,face1,505,270,face1,545,300,face1)
# couple and rest
#mcoup=maskmaker(cdand2,8,50,"c1", gyt=50,et=60,test=true,ft=100,fet=110,lx=320,rx=500,by=90)
#mcoup=emarker(cdand2,8,50,"epl",gyt=1, lt=2, test=true,ft=50,fl=2)
mcoup=emarker(cdand2,8,50,"epl",gyt=48, lt=2)
dcoup=drawlines(mcoup,8,50,398,32,405,28,420,355,430,320,388,50,388,70,360,15,375,35,408,15,418,28,407,0,407,10,line="diff")
cdcoup=colordrops(cdand2,dcoup,8,50,400,330,face1,350,50,blue,400,60,face1,480,50,face1,430,20,face1,370,10,face1,450,310,green)
drcoup=drawlines(b,8,50,0,250,120,300,180,370,300,270,320,330,400,330,620,479)
icoup=inlay(cdcoup,dcoup,drcoup,8,50,"below", color=red,w=620,y=250)
drcoup2=drawlines(b,8,50,25,0,30,40,10,70,10,100,50,130,50,180,20,230,50,270,200,40,200,0)
icoup2=inlay(icoup,dcoup,drcoup2,8,50,"hint",color=red,w=275,h=275)
icoup3=inlay(icoup2,dcoup,drcoup2,8,50,"hint",color=red,mwhite=false,w=275,h=275)
#maskmaker(icoup3,9,50,"c1", gyt=20,et=40,test=true,ft=120,fet=140,lx=500,rx=630,ty=350)
mchair=maskmaker(icoup3,9,50,"c1", gyt=54,et=74,lx=500,rx=630,ty=350)
dchair=drawlines(mchair,9,50,565,420,592,410,585,350)
cdchair=colordrops(icoup3,dchair,9,50,600,400,blue,600,440,blue,600,390,blue,590,420,face1,590,400,purple)
m=maskmaker(cdchair,10,50,"c1", gyt=1,et=80,lx=150,rx=450,ty=270)
l=drawlines(b,10,50,160,470,160,450,180,410,210,400,320,370,350,410,450,450,370,460,320,470,160,470)
i=inlay(cdchair,m,l,10,50,"vint",color=yellow,mwhite=false,x=160,w=315,y=320,h=159)
Trim(i,10,10) +trim(i,51,51) + trim(tr,0,1)
#return(grid(i,0,50,color=$7777))
#return(pallet(b,162,217))
I have tried to use colors mostly that look like those in original. But to demonstrate that they can be changed as one likes by showing the cake white icing as chocolate.
There are still some spots that are not colored or some areas that had color leaked from adjacent objects. These could be taken care of by manual intervention by drawing boundary lines.
It took about 170 lines of script to acheive this and two weeks of 6 hours a day work to get this. But by experience one can shorten this very much. I have also used part of time to fine tune my software.
The processing time is about 2 seconds per frame.
Last time I reported in haste a problem which I attributed to Avisynth and later found to be a bug in my plugin. But this time I ran into one which is strange. Before I attribute it to Avisynth I will describe it.
In the last fewlines I used a maskmaker function starting from frame 9 itself. Then I started to see some old frames as output, and no action occuring. If my plugin is at fault then I should get output of cdchair. But I get a frame about 50 statements back. This function stops at frame 49. If I go past 49 and reverse frame by frame in virtualdub I suddenly start seeing the correct frame processed properly. After changing start frame number to 10 I get a correct process.
This is strange as I use this very function over 20 times in my script without any problem. Ofcourse I will check again and again before blaming Avisynth.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.