View Full Version : Find color palette
spoRv
27th February 2017, 16:29
I wonder if it's possible to get color palette, like the ones found in the following websites:
https://twitter.com/cinemapalettes
http://moviesincolor.com
Thanks in advance to anyone that would eventually find a solution!
Reel.Deel
27th February 2017, 16:53
Something similar was discussed here: http://forum.doom9.org/showthread.php?t=167769
There's even a plugin in post #28. (http://forum.doom9.org/showthread.php?p=1631942#post1631942)
Hope it helps.
spoRv
27th February 2017, 21:21
Reel.Deel, thanks for the link! Didn't know that function, but I use MovieBarCode, that seems similar.
I tried to use the function in post #25 (https://forum.doom9.org/showpost.php?p=1626756&postcount=25) but it works only for video (no audio graph overlaid), while audio function alone found in the previous post #24 (https://forum.doom9.org/showpost.php?p=1626743&postcount=24) works... :confused:
What I'd like to get is some colored boxes like the ones found in the linked pages in the first post, or, in alternative, sort somehow the lines of the Fingerprint (or MovieBarCode) by color...
Cary Knoop
27th February 2017, 21:32
I was wondering could we make a script showing a number of pallets for a frame or multiple frames by converting to a perceptual colorspace, e.g. a space where the Euclidean distance between RGB values is equivalent to our perception of color difference (would the LAB color space be useful for this?) then grouping all pixels by a number of clusters, then ordering each group and averaging them, to eventually wind up with a frame with a number patches of colors?
spoRv
3rd March 2017, 17:33
I modified slightly the MovieBarCode script [link (https://forum.doom9.org/showthread.php?p=1799347#post1799347)] to obtain just the color average instead resized frame.
Now I wonder if someone could chime in, and write a script that will get them sorted as #000000 -> #FFFFFF, and, if possible, get the most used colors (and surrounding ones) as a palette of a given X numer - like the ones found in the first post links.
:thanks:
raffriff42
4th March 2017, 00:12
Speaking of palette grabbers, have you seen this (https://color.adobe.com/create/color-wheel/?base=2&rule=Shades&selected=4&name=silverghost-pulp--id-1440x900&mode=rgb&rgbvalues=0.1006814921090387,0.39313725490196083,0.2948529411764357,0.24153515064562403,0.9431372549019609,0.7073529411763869,0.16470588235294117,0.6431372549019608,0.4823529411764706,0.17751076040172162,0.6931372549019609,0.5198529411764091,0.13909612625538015,0.5431372549019609,0.4073529411764224&swatchOrder=0,1,2,3,4)? Quite amazing.
Get a palette from an image using different desired "moods"...
https://www.dropbox.com/s/u1bkzo0v5zzc6nn/adobe-color-cc-s01.png?raw=1
(See the circles in the image? They are the color samples, chosen by the program. You can drag them around to select different colors)
Manually choose a "main" color (or start from the image palette above) and let the page suggest some others, based on color rules
("complementary", "analogous", etc)
https://www.dropbox.com/s/f7zvc29n8ylq737/adobe-color-cc-s02.png?raw=1
spoRv
4th March 2017, 00:38
It's a great tool! But not what I'm looking for... :)
I'm pretty sure that it's possible to do that, the fact is I don't know how... one possible way that I thought (but not the best to follow) is to save any the desired frame (averaged colors and reduced to, let's say, 1x1 pixel) as png images with its hex color, and then read them all, sorted by name, stacked as a color bar... ugly technique, uh? But it should work - I think.
StainlessS
4th March 2017, 03:49
sporV, below takes you part way there. (3rd function example. not terribly fast).
https://forum.doom9.org/showthread.php?p=1799396#post1799396
EDIT: Taking only the most significant x number of bits of each color primary (and rounding where necessary)
would reduce the sort times and probably give more manageable results, you want this ?
spoRv
4th March 2017, 12:17
StainlessS, you are my hero! :D
Yep, most significant bits would be probably the best way to go, to get a limited palette.
What I would get are the 16 most used colors, with two sets of variables, one sorted by use (use01...use16) where use01 is the most used, and use16 is the 16th most used, and one sorted by color (col01...col16) where col01 would be #00 and col16 would be #FF. Related percentages variables (absolute in relation to all the color present, and in relation only with those 16 colors) would be really appreciated... ;)
I get the average color of each frame using this line borrowed by Gavino here (https://forum.doom9.org/showthread.php?p=1552534#post1552534):
mt_lutf(last, mode="avg", expr="x", u=3, v=3)
but sometimes I feel it's not... right... can't explain...
I tried to do this before the average:
pointresize(4,4)
and result is different. But which could be right one to get the "color feel" of each frame? Or, maybe, it would be better to use the most used color (#xx)?
Another question, unrelated - eventually I would start a new post: I would like also to get info from Mediainfo - resolution, bitrate etc.; the best way would be copy data & paste into a txt file, then let Avisynth read it; something like this (https://forum.doom9.org/showthread.php?p=1588523#post1588523), but I cannot find the right way... may you write a simple script to just get two or three vars? Just to get a template...
I know I'm a pain in the... neck!
StainlessS
4th March 2017, 14:47
I was thinking maybe reduce to 4 bits per channel (3*4 = 12 bits = 4096 colors [max possible]). Would still need some decision work on which to choose.
2 bits (*3=6 bits = 64 colors) would not I think be a good idea.
I did something like above on Amiga, picking blackest black, whitest white, redest red, greenest green and bluest blue.
Remainder were I think chosen based on mixture of color counts, dithering mixture result when mixed with already chosen colors, and
horizontal edges (for HAM Hold and Modify mode register colors).
There is something here on MediaInfo use:- https://forum.doom9.org/showthread.php?p=1759514#post1759514
And something by Martin53 from PM, not sure if I've changed anything (fragment of bigger script).
Function GetMediaInfo(string s) {
sFile = RT_GetFullPathName(RT_LocalTimeString() + ".avs")
sCommand = """CMD /C chcp 1252>nul && MediaInfo --Output=Video;fc=0%FrameCount%\nnof=0%NumberOfFrames%\nfr=0%FrameRate%\n""" +
\ """fr_nom=0%FrameRate_Nominal%\nduration=0%Duration%\nPAR=0%PixelAspectRatio% """ + RT_QuoteStr(s) + " >" + RT_QuoteStr(sFile)
CallCmd(BlankClip, Open=sCommand, Hide=true, debug=false, Synchronous=7)
Import(sFile)
RT_FileDelete(sFile)
global MediaInfoFramerate = fr>0 ? float(fr) : float(fr_nom) # if %FrameRate% empty: fallback %FrameRate_Nominal%
global MediaInfoFramecount = fc>0 ? fc : nof>0 ? nof : round(MediaInfoFramerate * duration / 1000) #if %FrameCount% empty:
\ fallback %NumberOfFrames% 2nd fallback Video;%Duration%
global MediaInfoFramecount = (MediaInfoFramecount > 999999) ? round(MediaInfoFramecount/1000) :
\ MediaInfoFramecount #Framecount over 1 million is MediaInfo bug
global MediaInfoPAR = (PAR == 0.843000) ? 1.183000 : PAR #MediaInfo bug
GScript(""" #"
if (MediaInfoFrameCount == 0) {
#Framecount still empty: fallback Duration*Framerate
sCommand = "CMD /C CHCP 1252 && MediaInfo --Output=General;duration=0%Duration% " + RT_QuoteStr(s) + " >" + RT_QuoteStr(sFile)
CallCmd(BlankClip, Open=sCommand, Hide=true, debug=false, Synchronous=7)
Import(sFile)
RT_FileDelete(sFile)
RT_DebugF("duration for %s = %i", s, duration, name="GetMediaInfo")
if (duration != 0) { global MediaInfoFramecount = round(MediaInfoFramerate * duration / 1000) }
}
""") #"
assert(MediaInfoFramecount != 0 && MediaInfoFramerate != 0 && MediaInfoPAR != 0, "MediaInfo incomplete data '"
\ +string(MediaInfoFramecount)+"'"+string(MediaInfoFramerate)+"'"+string(MediaInfoPAR)+"'")
# Select: 0=FrameCount, 1=FrameRate, 2=PAR
RT_DebugF("FPS=%f Framecount=%d PAR=%f", MediaInfoFrameRate, MediaInfoFrameCount, MediaInfoPAR, name="GetMediaInfo")
}
EDIT:
Remainder were I think chosen based on mixture of color counts, dithering mixture result when mixed with already chosen colors,
Actually, I think stuff in blue was actually choosing colors most distant (RGB color cube) to those already chosen, which more or less amounts to the same thing.
EDIT: And something I was playing with to extract numeric Int single data item only.
Function GetMediaInfoItem(String Section,String Item,String VidFn,Bool "Debug",Bool "DelOutputFile") {
# Returns with output filename in string, or Int(-1) on error.
myName="GetMediaInfoItem: " DelOutputFile=Default(DelOutputFile,True) Debug=Default(Debug,False)
ret = -1
if(!RT_VarExist("DB_SpliceOpenClip_MEDIAINFO_UNAVALABLE")) {
VidFn=RT_GetFullPathName(VidFn)
LogFn=RT_GetFullPathName("MediaInfo_"+RT_LocalTimeString(File=true)+".txt") # Unique-ish filename, full path
MiCmd="MediaInfo.Exe --LogFile="+Chr(34)+LogFn+Chr(34)+" " +
\ "--Inform="+Section+";" + "%"+Item+"% " + Chr(34) + VidFn + Chr(34) + " "
RT_FileDelete(LogFn) # Delete output file prior to Call (Unlikely to ever Exist)
CallCmd(BlankClip(Length=1), Open=MiCmd, Hide=true, debug=Debug, Synchronous=1) # Call the command, wait command terminated.
if(Exist(Logfn)){
Ret=RT_ReadTxtFromFile(LogFn).RT_TxtGetLine
(Debug) ? RT_DebugF("MediaInfo::%s;%%%s%% = '%s'",Section,Item,Ret,name=myName) : NOP
(DelOutputFile) ? RT_FileDelete(LogFn) : NOP
} else {
(DEBUG) ? RT_DebugF("%s FAILED",MiCmd,name=myName) : NOP
Global DB_SpliceOpenClip_MEDIAINFO_UNAVALABLE=True
}
}
return Ret
}
Function GetMediaInfoItemNumber(String Section,String Item,String VidFn,Bool "Debug",Bool "DelOutputFile") {
Ret = GetMediaInfoItem(Section,Item,VidFn,Debug=Debug,DelOutputFile=DelOutputFile)
Return (Ret.IsString) ? RT_NumberValue(Ret) : Ret
}
AudioCount=GetMediaInfoItemNumber("General","AudioCount",FN,Debug=Debug)
You will likely want path to MediaInfo in your Path environment variable (I use C:\BIN\).
EDIT: something like this could be used for Float item result (untested)
Function GetMediaInfoItemFloat(String Section,String Item,String VidFn,Bool "Debug",Bool "DelOutputFile") {
Ret = GetMediaInfoItem(Section,Item,VidFn,Debug=Debug,DelOutputFile=DelOutputFile)
Return (Ret.IsString) ? Value(Ret) : Ret
}
spoRv
4th March 2017, 18:43
Yes, I thought about 4 bits ($FFF = 16*16*16 = 4096 colors). Aim is to get something like this:
https://pbs.twimg.com/media/Cln3AciWMAEx2CI.png
with two palettes for the actual frame, and two for the whole clip (that should be analyzed once, and stored in a file, I suppose); one for the most used colors sorted by importance, and the other sorted from black to white.
Mediainfo: I took a look at your thread, wow... I think I should study it (a lot) to try to understand something!
A different approach - simpler for my small mind, but should work, and it could be used by anyone who have just avisynth installed, with no additional plugin - is to create an "avisynth" template on Mediainfo, so when I visualize data on it, I should just copy & paste the result into an avisynth script, and variables would be ready there, something like
Pixel_Aspect_Ratio="%PixelAspectRatio%\r\n"
Display_Aspect_Ratio="%DisplayAspectRatio%\r\n"
and so on, so I could implement them in carefully placed subtitles.
What do you think?
Thanks in advance for your patience, I know you need it a lot with me... :D
:thanks: :thanks: :thanks:
StainlessS
4th March 2017, 19:56
There is some kind of template mode in that thread, Martin53 created template (in given snippet) that can be used in an Eval().
I've done mod,wanna give it a test drive ?
Added Args x,y,w,h (area in question), Mask (planar), MaskMin, MaskMax, where Mask given and Luma pixels in mask between MaskMin, MaskMax then gives count only on those. Also Int msb most significant bits. Seems to be working OK.
Good idea to test return value of the function to detect 0 pixels detected (have to be in x,y,w,h and mask valid, otherwise 0 count returned).
Oh, I have not done any rounding (up or down scale). Think there was a thread in devs somewhere on rounding and such,
dont know what was decided as being best, so I've just converted eg $FF -> $F, and $F back up to $F0. Easily changed if
anybody can point to better method.
spoRv
4th March 2017, 22:48
Test drive? Sure! :D
StainlessS
5th March 2017, 11:13
Script to show all colors in a frame
Global Cnt_Color_Fld = 0
Global Cnt_Count_Fld = 1
Global ColorsPerFrame = 10 # Max 16
DB1 = "RGB_COUNT1.DB"
DB2 = "RGB_COUNT2.DB"
DB3 = "RGB_COUNT3.DB"
FRAME=19733
MSB1=3
MSB2=4
MSB3=5
Avisource("f:\v\jurassicPark.Avi").ConvertToRGB32.Trim(FRAME,-1).KillAudio
RoboCrop
###
ORG=Last
###
A=Doit(DB1,Last,MSB1).BilinearResize(ORG.Width,Org.Height)
B=Doit(DB2,Last,MSB2).BilinearResize(ORG.Width,Org.Height)
C=Doit(DB3,Last,MSB3).BilinearResize(ORG.Width,Org.Height)
###
LFT=StackVertical(ORG,A)
RGT=StackVertical(B,C)
StackHorizontal(LFT,RGT)
Return last.AssumeFps(1.0)
Function Doit(String DB,clip c,Int msb) {
c
RT_DBaseRgbColorCount(DB,Last,0,msb=MSB) # Count colors of frame 0 (originally FRAME).
RT_DBaseQuickSort(DB,Field=Cnt_Count_Fld,Field2=Cnt_Color_Fld,Ascend=False) # Sort Descending (biggest count at record 0)
ShowFrameColorsRGB(DB,ColorsPerFrame)
}
Function ShowFrameColorsRGB(String DB,Int "ColorsPerFrame") {
myName="ShowFrameColorsRGB: "
ColorsPerFrame=Default(ColorsPerFrame,10)
Assert(DB!="" && Exist(DB),RT_String("%s DB is empty string or does not exist",myName))
Assert(ColorsPerFrame>=1&&ColorsPerFrame<=16,RT_String("%s 1 <= ColorsPerFrame <=16 (%d)",myName,ColorsPerFrame))
DB=RT_GetFullPathName(DB)
FuncS="""
Function QRecDat@@@(String DB,int n) {
RGB = RT_DBaseGetField(DB,n,Cnt_Color_Fld)
COL = T@@@.BlankClip(color=RGB).LetterBox(2,2,2,2)
ORD = T@@@.BlankClip(color=$FFFFFF).Subtitle(RT_String("%d/%d",n+1,RECORDS@@@),Align=5).LetterBox(2,2,2,2)
CNT = T@@@.BlankClip(color=$FFFFFF).Subtitle(RT_String("%d",RT_DBaseGetField(DB,n,Cnt_Count_Fld)),Align=5).LetterBox(2,2,2,2)
RGBC = T@@@.BlankClip(color=$FFFFFF).Subtitle(RT_String("$%06X",RGB),Align=5).LetterBox(2,2,2,2)
Return StackHorizontal(COL,ORD,CNT,RGBC)
}
Function Fn@@@(clip dummy,String DB,int cpf) {
n = current_frame
SRec = n * cpf
Last = HEAD@@@
for(i=0,cpf-1) {
Q = (SRec+i < RECORDS@@@) ? qRecDat@@@(DB,SRec+i) : BAR@@@
StackVertical(Last,Q)
}
Return Last
}
H=48
#######################################
Global RECORDS@@@ = RT_DBaseRecords(DB)
Global T@@@ = BlankClip(length=1,width=128,height=H,pixel_type="RGB32").KillAudio
COL = T@@@.BlankClip(color=$FFFFFF).Subtitle("Color",Align=5).LetterBox(2,2,2,2)
ORD = T@@@.BlankClip(color=$FFFFFF).Subtitle("Order",Align=5).LetterBox(2,2,2,2)
CNT = T@@@.BlankClip(color=$FFFFFF).Subtitle("Count",Align=5).LetterBox(2,2,2,2)
RGBC = T@@@.BlankClip(color=$FFFFFF).Subtitle("RGB",Align=5).LetterBox(2,2,2,2)
Global HEAD@@@ = StackHorizontal(COL,ORD,CNT,RGBC)
Global BAR@@@ = HEAD@@@.BlankClip
Global BLK@@@ = BAR@@@.BlankClip(Height=ColorsPerFrame*H)
Global HEAD@@@ = HEAD@@@.LetterBox(0,8,0,0)
Pages = (RECORDS@@@ + ColorsPerFrame - 1) / ColorsPerFrame
StackVertical(HEAD@@@,BLK@@@).BlankClip.Loop(Pages,0,0)
#######################################
ARGS = "DB,ColorsPerFrame"
Last.GScriptClip("Fn@@@("+ARGS+")", local=true, args=ARGS)
"""
GIFunc ="ShowFrameColorsRGB" # Function Name, Supply unique name for your multi-instance function.
GIName =GIFunc+"_InstanceNumber" # Name of the Instance number Global
RT_IncrGlobal(GIName) # Increment Instance Global (init to 1 if not already exists)
GID = GIFunc + "_" + String(Eval(GIName))
InstS = RT_StrReplace(FuncS,"@@@","_"+GID)
# RT_WriteFile("DEBUG_"+GID+".TXT","%s",InstS)
Return GScript(InstS)
}
Here @ Most Significant Bits=8(all colors), for single source movie (Jurassic Park) frame totalling about 84,000 colors,
creates sequence of about 8400 output frames showing 10 colors per frame, just imagine how much fun
you could have viewing all of the colors of the other 200,000 frames in the movie, could keep you busy all day.
https://s20.postimg.org/8we2246m5/Show_Frame_Colors_RGB_zpsskmanyut.png (https://postimg.org/image/yrxslb8ft/)
EDIT: Changed to MultiInstance script showing 3 version of MSB.
spoRv
6th March 2017, 00:28
Away from PC, I would try it ASAP. What dependencies are needed?
Jurassic Park: at the end, the palette for the whole movie is... made of some sort of navy blue shades? That's strange... or that's only for those 8400 frames?
StainlessS
6th March 2017, 05:11
What dependencies are needed?
RT_Stats latest (v2 beta 9).
RoboCrop, unless you want to count black pixels in border (quite a few in Jurassic park DVD).
GScript, and Grunt.
I changed sort order to most common pixels 1st in list, ie first frame.
Count shows total pixel count for that color.
You would probably not want to view MSB=8, just not much use. The image you chose (kids outside store) does not
really seem to have much variation of color in it
and so you could select similar colors to your selection quite easily by hand, Jurassic park frame chosen has a myriad of
totally different colors and I would not know where to start to pick out a dozen.
The modded 3X script shows MSB=3, =4, and =5, ie RGB color cube chopped up into smaller cubes, ie
MSB==3=512 cubes(8x8x8), MSB==4=4096 cubes(16*16*16), MSB==5=32768 cubes(32*32*32), first colors in output colors list
are highest pixel count in those smaller cubes.
Frame lists show Color, Order in list (EDIT: Together with total number of colors in list), pixel count, and Hex RGB.
I'm still not sure what it is you want to achieve, conversion to limited color count image format eg GIF ?
I dont really get the purpose for the palette selection, nor the whole movie FingerPrint thing,
what use is it ?
Also, is there a specific number of colors required in palette ?
StainlessS
6th March 2017, 05:56
Your kids outside store image with MSB=3
https://s20.postimg.org/3z0hh04n1/Show_Frame_Colors_RGB_X1_zpsqve0awiu.gif (https://postimg.org/image/uk30ck709/)
EDIT: In actual fact there are more colors in your kids outside store pic, its just that they are nearly all the same.
MSB=8, ie 16 millions colors (148000 unique colors, as opposed to Jurassic park image 84000, but your pic is much bigger)
https://s20.postimg.org/fpeeydxfh/Kids_Msb80_zpsnxtjnnsw.png (https://postimg.org/image/pmpfrg515/)
spoRv
6th March 2017, 12:02
The aim of a movie fingerprint is to get an unique ID for any movie version - talking about Jurassic Park, an ID for JP on BD, on DVD, on 3D BD - that would be useful to spot differences in color grading - they are all different, but for example the US BD could be the same of EU BD, for example.
So the moviebarcode is an interesting way of representing a whole movie in a single image, like the following (Aliens, top BD, bottom LD):
https://s22.postimg.org/voh5lclwh/Aliens_SE_Top_BD_Bot_LD_Film_Bar_Code.png
a wonderful thing would be to find the way to sort those bars from darker (#000000) to brighter (#FFFFFF).
But I would add also few frames from the movie, with a related palette, and a palette of the whole film.
The fact is, I have not a clear idea of how to get the "right" palette out of a frame... I thought about most used colors, don't know if it's the best, though!
Another idea: it would be great also to have a graph of the scene changes, like alternate black and white bars - that, with 1280 pixels, the sample would be less than two seconds, sufficient for almost all the movies, apart the fastets.
Or, a "movement" graph...
What do you think about these ideas? I know there are similar attempts, but none - apart moviebarcolor - made using avisynth AFAIK.
StainlessS
6th March 2017, 16:53
OK, I can see that it could have use to be able to tell if two films are dissimilar via the Fingerprint thing.
But not sure that anything could be gotten from any palette, if two films are
already known to be different via your fingerprint, comparing palettes may be akin to comparing apples
with pomegranates with inevitable secondary dissimilar result that could probably have been foretold from the first.
I can tell from above, that the BD is dark and dismal, and that the DVD is bright and sparkly,
glad I never got around to getting a BD :)
EDIT:
I thought about most used colors, don't know if it's the best, though!
Max unique color count for Jurassic park was 213, and for kids frame was 12420, the pomegranates thing again.
Max color count is probably not good idea (at least on its own), comparing supposed exact same frames might
bring results closer together but dissimilarities in grading would produce random differences likely resulting in
different palette being chosen making differences even greater.
I may have a try at extracting some kind of palette information from maximum count in localised area, but I may well be
wasting my time completely. You though, have to decide how many colors are required, and what to do in say instance
where frame is nearly single color (only nearly only two colors, etc).
spoRv
7th March 2017, 05:29
Let's try to use the moviebarcode as source for the palette.
So, reduce the colors from 24bit to 6bit (possibly rounding the similar ones to the ones most used) get a limited palette of 64 colors; now, extract the X most used colors (variable from, let's say, 4 to 16?) and have those two series of variables, one sort by most used, and one sort from darkest to brightest.
This should be simpler to obtain, I hope!
Really, I don't want you getting crazy to make this function; if you feel you would do it, take all the time you need!
Again, thanks for all your efforts!
StainlessS
7th March 2017, 12:54
24bit to 6bit (possibly rounding the similar ones to the ones most used) get a limited palette of 64 colors
That reduction from 24 to 6 bit would already have reduced to 64 possible colors, with nothing left to do, only the pixel counts at each color
would perhaps have any value. (The MSB=2 type stuff does exactly that). Better would be to choose 64 colors (in 24 bit).
The eg MSB=3 (LSB=8-MSB,=5) type thing just gives a rough estimate to number of pixels occupying a small sugar cube within the large RGB color cube.
The number of small sugar cubes would be (2 ^ (3*MSB)),= 512.
Number of sugar granules (24 bit color) in sugar cube would be (2 ^ (3*LSB)),=32768.
Total number of sugar granules in RGB cube = 512*32768=16777216=(2 ^ (3*8))=(2^24).
REally, anything like this would be better be done in some dedicated app with plenty of memory, Avisynth and RT_DBase is always gonna be a struggle
in comparison, but we are gonna give it a bit of a go. But first we need a few more utility funcs, I've just implemented ability to delete a range of records
from a DBase, also just about done a field search on range of records within a DBase, I think these two at least would be needed to get anywhere
(within any kind of reasonable time period, doing things via script calls to individual records would be just too damn slow.
Anyway, have to leave in about 20 mins, so bye for now.
PS, using FingerPrint would indeed make it much more possible.
spoRv
7th March 2017, 14:55
Yes, I think using the MovieBarCode with "only" 1280 colors (at best) could make it "quite easy" in comparison to, say, check the colors of 200,000 frames of a whole movie!
raffriff42
7th March 2017, 15:44
I wonder if it's possible to get color palette, like the ones found in the following websites...
or, in alternative, sort somehow the lines of the Fingerprint (or MovieBarCode) by color...
Now I wonder if someone could chime in, and write a script that will get them sorted as #000000 -> #FFFFFF, and, if possible, get the most used colors (and surrounding ones)
but sometimes I feel it's not... right... can't explain...
The aim of a movie fingerprint is to get an unique ID for any movie version - talking about Jurassic Park, an ID for JP on BD, on DVD, on 3D BD - that would be useful to spot differences in color grading - they are all different, but for example the US BD could be the same of EU BD, for example.
Another idea: it would be great also to have a graph of the scene changes, like alternate black and white bars
Or, a "movement" graph...
With such a clear statement of the problem, it's no wonder a solution is difficult to arrive at.
I know there are similar attempts, but none - apart moviebarcolor - made using avisynth AFAIK.
So what is the point? Beside making more unpaid work for StainlessS?
spoRv
8th March 2017, 01:26
The point is to obtain an avisynth script that could generate a movie fingerprint with more info than a simple moviebarcode, that's it.
I thank StainlessS a lot, for all his time and efforts. And yes, I think I'm asking him too much any time... but he's so kind I can't resist! ;)
THANKS STAINLESSS!!!
raffriff42
8th March 2017, 04:57
Sorry if I was harsh. Stating the problem clearly is not an easy thing to do, and most people don't do it. I've been guilty myself. But doing it is essential.
BTW if I wanted to extract a palette, I think I would use ffmpeg:ffmpeg -ss <start> -t <dur> -i "AAA.mov" ^
-vf "palettegen=max_colors=128:reserve_transparent=0" ^
"AAA palette128.png"
Here's a palette from the post #11 (https://forum.doom9.org/showthread.php?p=1799473#post1799473) image (cropped). At least 128 colors were needed to get a good looking palette IMHO.
https://www.dropbox.com/s/irno10ypwhz4lio/Cln3AciWMAEx2CI%20palette128%20big.png?raw=1
FFmpeg palettes are arranged in rows, 16 across, in ascending luminance order.
StainlessS
8th March 2017, 08:20
spoRv, I very much doubt that I could do any better than Raffs ffmpeg example, and I imagine that it is a lot faster than anything I could do.
Raff, was totally unaware that ffmpeg did that, very impressive, thanx. (I bet its fast too, split second, yes ?).
EDIT: If I could do it with RT_ in less that half an hour, I would be well impressed with myself :)
spoRv
8th March 2017, 16:03
raffriff42, no worry, I know I can seem a bit too much insistent...
I tried your script using FFMPEG for Audacity that is installed in my PC, but it doesn't work... should I try another version?
rvs75
8th March 2017, 16:37
You can do some tests with this program (C#) :
https://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C
In the code, the palette is already accessible (IcolorQuantizer.GetPalette, return a List<Color>). Some code is necessary for export the palette.
Perhaps, a preprocessing (reduce luminance dynamic ?) can improve the palette.
Sparktank
8th March 2017, 20:30
should I try another version?
Zeranoe builds are more updated and preferred.
https://ffmpeg.zeranoe.com/builds/
The ones Audacity makes are centuries old, unless you use external FFMPEG for export-only.
And who knows what else they leave out as they're only making their own builds for importing limited file support.
rvs75
8th March 2017, 21:57
mtPaint ?
http://img4.hostingpics.net/thumbs/mini_55414320170308215419SimplePaletteQuantizerMicrosoftVisualStudio.png (http://www.hostingpics.net/viewer.php?id=55414320170308215419SimplePaletteQuantizerMicrosoftVisualStudio.png)
raffriff42
8th March 2017, 21:59
Raff, was totally unaware that ffmpeg did that, very impressive, thanx. (I bet its fast too, split second, yes ?).Very fast, even when processing movies. I was grabbing very short sections, like 2-3 seconds.
Future enhancements might involve 1) dividing into scenes (or maybe GOPs), 2) grabbing palettes as images, 3) squeezing and stacking them to look something like the fingerprint thingy.
My point was to show you don't have to think about palette extraction at a low level - it's already been done, many times over.
Here's another extractor, with very nice subjective results - much like Adobe's I posted before (https://forum.doom9.org/showthread.php?p=1799381#post1799381). It's Javascript, open source.
http://jariz.github.io/vibrant.js/
rvs75
8th March 2017, 22:52
http://lokeshdhakar.com/projects/color-thief/
spoRv
9th March 2017, 12:57
Thanks for your effort guys! :thanks:
http://lokeshdhakar.com/projects/color-thief seems the perfect solution: I generate the MovieBarCode in avisynth, and feed it to the javascript; that's what I needed! (the author created also Lightbox!)
(Another interesting solution is this: http://www.cssdrive.com/imagepalette)
Now (don't shoot me, please!) the more-than-perfect solution would be to find out an avisynth script that do the same, or call the local javascript (using https://github.com/Xenoveritas/jsvsynth maybe)... I know, I ask a lot... if it's possible, that will be great, so no manual intervention would be needed.
pseudocode:
# load source
avisource...
# call moviebarcode avisynth function
barcode=moviebarcode
# call color-thief javascript function, X = colors in the palette
palette=colof-thief(X)
# stack both
stackvertical(barcode,palette)
StainlessS
9th March 2017, 21:50
I personally would not look forward to jumping through all of the hoops entailed in going the JavaScript way, ie learning JavaScript,
Compiling Jsvsynth (along with using Cygwin etc), just to get to a state where I might be able to start doing something.
Would you be happy with Raffs ffmpeg, called via Avisynth script, and returning the stacked barcode,palette, result ?
spoRv
9th March 2017, 23:27
Still not attempted to use Raffs' ffmpeg, but I downloaded the Color Thief javascript, and it's very nice! I'll grab the screen with its result, cut&paste the palette to a paint program, save as PNG and load in avisynth along with the moviebarcode; just few manual steps more.
Thanks to everyone for your help and time! :thanks:
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.