chmars
9th June 2021, 17:23
Hello,
Film transfer.
I have white perforations, they disturb during dark scenes.
I don't wish to crop the image too much, so part of the perfos will stay.
I Borrowed from Zorr Delta Restore Script.
I managed to:
-make a mask,
-blur it a vertically more than horizontally,
-fill the perfos with dark gray,
SetMemoryMax(8000)
threads = 8
SetFilterMTMode("DEFAULT_MT_MODE", 2)
source1=FFVideoSource(464-13_63.mov").KillAudio()
source1 = Crop(source1, 500,0,-130,-60)
perfo = LumaDeltaMask(source1, ">", brightness=1.15, spotSize=90)
fill_color = BlankClip(source1,color=$26282d)
expandtimes = 7
for (i = 1, expandtimes) {
perfo = perfo.mt_expand( chroma="-127")
}
perfo = perfo.FastBlur(2, 5)
filled = Overlay(source1,fill_color,mask=perfo)
result=StackHorizontal(source1, filled)
return(result)
#########################################################################################################################
function RemoveSmallSpots(clip mask, int spotSize) {
mask_orig = mask
# remove too small spots ----------------------------------------------------
for (i = 1, spotSize) {
mask = mask.mt_inpand()
}
mask = mt_hysteresis(mask, mask_orig, chroma="-127")
return mask
}
function LumaDeltaMask(clip source, string direction, float "brightness", int "spotSize") {
# direction is ">" if you want mask to contain areas where source is brighter than filtered by "brightness", direction "<" selects where source is darker
# adjust brightness to change how bright objects are selected, typical values between 1.0 and 1.1, larger value = brighter object
# spotSize controls the smallest spot size allowed in the mask, typical values between 0 and 3
brightness = Default(brightness, 0.9)
spotSize = Default(spotSize, 2)
gray = BlankClip(source, color=$c0c0c0)
# diff
diff = Grayscale(mt_makediff(source, gray ))
# mask
mask = mt_lut(diff, expr="x range_half "+String(brightness)+" * " + direction + " 255 scalef 0 ?")
# remove too small spots
mask = RemoveSmallSpots(mask, spotSize)
return mask
}
Prefetch(threads)
https://nmldqjct.preview.infomaniak.website/shared_files/index.php/s/1NuaNCeMUE7aSg2/download
Source video (https://nmldqjct.preview.infomaniak.website/shared_files/index.php/s/XAqwhj9gw8j6CFo/download)
Even cropped more, it's not discrete, because the tint is wrong.
I found some filters to analyse the color of a pixel but I didn't manage to use them with with my color format.
I also don't figure out how to say "take an average of the color at a place, relative to the mask place".
I'd like to analyse the color near the perforations and use it to fill them. This, before grading, on a YUV422P16 image.
Any idea of directions to search for the right tools?
Film transfer.
I have white perforations, they disturb during dark scenes.
I don't wish to crop the image too much, so part of the perfos will stay.
I Borrowed from Zorr Delta Restore Script.
I managed to:
-make a mask,
-blur it a vertically more than horizontally,
-fill the perfos with dark gray,
SetMemoryMax(8000)
threads = 8
SetFilterMTMode("DEFAULT_MT_MODE", 2)
source1=FFVideoSource(464-13_63.mov").KillAudio()
source1 = Crop(source1, 500,0,-130,-60)
perfo = LumaDeltaMask(source1, ">", brightness=1.15, spotSize=90)
fill_color = BlankClip(source1,color=$26282d)
expandtimes = 7
for (i = 1, expandtimes) {
perfo = perfo.mt_expand( chroma="-127")
}
perfo = perfo.FastBlur(2, 5)
filled = Overlay(source1,fill_color,mask=perfo)
result=StackHorizontal(source1, filled)
return(result)
#########################################################################################################################
function RemoveSmallSpots(clip mask, int spotSize) {
mask_orig = mask
# remove too small spots ----------------------------------------------------
for (i = 1, spotSize) {
mask = mask.mt_inpand()
}
mask = mt_hysteresis(mask, mask_orig, chroma="-127")
return mask
}
function LumaDeltaMask(clip source, string direction, float "brightness", int "spotSize") {
# direction is ">" if you want mask to contain areas where source is brighter than filtered by "brightness", direction "<" selects where source is darker
# adjust brightness to change how bright objects are selected, typical values between 1.0 and 1.1, larger value = brighter object
# spotSize controls the smallest spot size allowed in the mask, typical values between 0 and 3
brightness = Default(brightness, 0.9)
spotSize = Default(spotSize, 2)
gray = BlankClip(source, color=$c0c0c0)
# diff
diff = Grayscale(mt_makediff(source, gray ))
# mask
mask = mt_lut(diff, expr="x range_half "+String(brightness)+" * " + direction + " 255 scalef 0 ?")
# remove too small spots
mask = RemoveSmallSpots(mask, spotSize)
return mask
}
Prefetch(threads)
https://nmldqjct.preview.infomaniak.website/shared_files/index.php/s/1NuaNCeMUE7aSg2/download
Source video (https://nmldqjct.preview.infomaniak.website/shared_files/index.php/s/XAqwhj9gw8j6CFo/download)
Even cropped more, it's not discrete, because the tint is wrong.
I found some filters to analyse the color of a pixel but I didn't manage to use them with with my color format.
I also don't figure out how to say "take an average of the color at a place, relative to the mask place".
I'd like to analyse the color near the perforations and use it to fill them. This, before grading, on a YUV422P16 image.
Any idea of directions to search for the right tools?