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. |
10th November 2015, 02:16 | #1 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Image Magick and stacked high bit-depth
In case this is useful to anyone, after a few hours of playing around thanks to poor documentation, here's how to convert to/from 16bit PNG images and Avisynth convention stacked high/low formats. This works with the 16bit version of imagemagick. Note that Linux users will have to escape the parenthesis.
http://www.imagemagick.org/script/bi...es.php#windows Need ImageMagick-6.9.2-5-Q16-x64 version convert 16bit to stacked (high/low): Code:
convert 16bit.png -depth 16 ( +clone -evaluate and 255 -evaluate multiply 256 ) -append stacked.png Code:
convert stacked.png -depth 16 -crop 100%x50% ( +clone -evaluate divide 256 ) -delete 1 -compose Add -composite -define png:bit-depth=16 16bit1.png Code:
convert source options output Code:
-depth 16 Code:
-crop 100%x50% Code:
( +clone -evaluate divide 256 ) -evaluate performs a mathematical operation on the image. Since we've set bit depth to 16, think in terms of 16bit numbers. An 8bit image is convert to 16bit by making it the high byte. Therefore, we need to add the top half (as 0xHH00) to the bottom half, shifted right by 8, or divided by 256. The new image is placed on the stack (as 0x00LL) Code:
-delete 1 Code:
-compose Add -composite Code:
-define png:bit-depth=16 Code:
16bit.png The inverse process should be easy to follow now. Code:
convert 16bit.png -depth 16 ( +clone -evaluate and 255 -evaluate multiply 256 ) Code:
-append keywords: stack16, deep colour, deep color, high bit-depth, 16-bit video, timelapse, raw frames, stacked format, image magick, 16bit to stacked, stacked to 16bit, 16bit PNG Last edited by jmac698; 10th November 2015 at 04:06. |
7th April 2017, 19:33 | #4 | Link |
Registered User
Join Date: Mar 2007
Posts: 407
|
It should work something like this - don't take it literally, please.
I made it in early february to process DNG or RAW files with AviSynth. 'Me' is just an object oriented programming mimicking shortcut of the script base name, the ImageMagick commands should work when their path is in the %PATH% variable and you need the CallCmd plugin. Code:
function Me() { Try { LeftStr(ScriptName(), StrLen(ScriptName())-4) } catch (err_msg) { assert(false, "'ScriptName()' is available from v2.60 only") } } if (!exist(Me+".png")) { cmd = "cmd /c convert "+Me+" -depth 16 ( +clone -evaluate and 255 -evaluate multiply 256 ) -append -depth 8 "+Me+".png" ColorBars.CallCmd(Hide=true,Debug=false,Open=cmd,Synchronous=7) } ImageReader(Me+".png") ######################################### # add your stacked format processing here ######################################### ImageWriter(Me+".png", 0, 0, type="png") cmd = "cmd /c convert "+Me+"000000.png -crop 100%x50% ( +clone -evaluate divide 256 ) -delete 1 -compose Add -composite -define png:bit-depth=16 "+Me+".out.png" CallCmd(Hide=true,Debug=false,Close=cmd,Synchronous=7) Last edited by martin53; 9th April 2017 at 10:24. |
10th April 2017, 18:24 | #5 | Link |
Registered User
Join Date: Feb 2003
Location: Russia, Moscow
Posts: 854
|
Hi martin53!
pinterf help me solve this problem: https://forum.doom9.org/showthread.p...52#post1802952 yup. |
|
|