An image can be deconstructed into a cartoon and texture.
set WEB_SIZE=-resize 600x600 set SRC=\pictures\20130713\AGA_1372_sRGB.tiff set SIG_BLR=20 rem goto skip %IM%convert ^ %SRC% ^ -strip ^ -crop 2300x2500+2300+2100 ^ +repage ^ +write ce_src.miff ^ ( +clone %WEB_SIZE% ^ +write ce_src_sm.jpg ^ +delete ) ^ -blur 0x%SIG_BLR% ^ +write ce_src_blr.miff ^ %WEB_SIZE% ce_src_blr_sm.jpg |
call %PICTBAT%cartTextEep ^ ce_src.miff ce_ctx_XX.miff %SIG_BLR% %IM%convert ^ ce_ctx_cart.miff ^ %WEB_SIZE% ^ ce_ctx_cart_sm.jpg |
set EDGES_SRC=ce_ctx_edges.miff %IM%convert ^ %EDGES_SRC% ^ -morphology Thinning:-1 skeleton ^ ce_seg0.miff call %PICTBAT%skel2SegBnd ^ ce_seg0.miff ce_ptbnd.miff 36 %IM%convert ^ ce_ptbnd.miff ^ %WEB_SIZE% ^ ce_ptbnd_sm.png :skip
%IM%convert ^ ce_ctx_edges.miff ^ %WEB_SIZE% ^ -threshold 10%% ^ ce_ctx_edges_sm.png |
|
%IM%convert ^ ce_seg0.miff ^ %WEB_SIZE% ^ -threshold 10%% ^ ce_seg0_sm.png |
|
%IM%convert ^ ce_ptbnd.miff ^ %WEB_SIZE% ^ -threshold 10%% ^ ce_ptbnd_sm.png |
For convenience, .bat scripts are also available in a single zip file. See Zipped BAT files.
rem From input image %1, rem makes cartoon and textures outputs rem using technique of Buades et al. rem %2 is output name, including XX, which will be substituted by cart or text. rem such that input = cartoon + texture - 50%. rem %3 is blur sigma. rem rem Future: allow for heavy blur. @if "%1"=="" findstr /B "rem @rem" %~f0 & exit /B 1 @setlocal enabledelayedexpansion @call echoOffSave call %PICTBAT%setInOut %1 ctxb set OUTFILE=%2 if "%OUTFILE%"=="." set OUTFILE= if "%OUTFILE%"=="" set OUTFILE=%BASENAME%_ctx_XX%EXT% set OUT_CART=%OUTFILE:XX=cart% set OUT_TEXT=%OUTFILE:XX=text% if "%OUT_CART%"=="%OUT_TEXT%" ( echo Bad OUTFILE [%OUTFILE%] -- should contain XX exit /B 1 ) echo OUT_CART=%OUT_CART% OUT_TEXT=%OUT_TEXT% set BLR_SIG=%3 if "%BLR_SIG%"=="." set BLR_SIG= if "%BLR_SIG%"=="" set BLR_SIG=1 set BLR_SIG2=%4 if "%BLR_SIG2%"=="." set BLR_SIG2= if "%BLR_SIG2%"=="" set BLR_SIG2=%BLR_SIG% rem This works best with Q32 HDRI. if "%IM32f%"=="" call %PICTBAT%setIm8.bat set BLR_IMG=%OUTBASE%_ctx_blr.miff set LTV_IMG=%OUTBASE%_ctx_ltv.miff set LTV_BLR=%OUTBASE%_ctx_ltvblr.miff set LAMBDA=%OUTBASE%_ctx_lambda.miff %IM32f%convert ^ %INFILE% ^ -blur 0x%BLR_SIG% ^ +depth ^ %BLR_IMG% call %PICTBAT%locTotVar %INFILE% %LTV_IMG% %BLR_SIG2% call %PICTBAT%locTotVar %BLR_IMG% %LTV_BLR% %BLR_SIG2% set sLEVEL= set sLEVEL=-level 25%%,50%% %IM32f%convert ^ %LTV_IMG% +write mpr:LTVIMG ^ %LTV_BLR% ^ -compose MinusSrc -composite ^ mpr:LTVIMG ^ -compose DivideSrc -composite ^ %sLEVEL% ^ +depth ^ %LAMBDA% %IM32f%convert ^ %INFILE% ^ %BLR_IMG% ^ %LAMBDA% ^ -compose Over -composite ^ +depth ^ %OUT_CART% %IM32f%convert ^ %INFILE% ^ %OUT_CART% ^ -compose Mathematics -define compose:args=0,-1,1,0.5 -composite ^ +depth ^ %OUT_TEXT% call echoRestore endlocal
All images on this page were created by the commands shown, using:
%IM%identify -version
Version: ImageMagick 6.9.5-3 Q16 x86 2016-07-22 http://www.imagemagick.org Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Visual C++: 180040629 Features: Cipher DPC Modules OpenMP Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
To improve internet download speeds, some images may have been automatically converted (by ImageMagick, of course) from PNG to JPG.
Source file for this web page is cartexamp.h1. To re-create this web page, run "procH1 cartexamp".
This page, including the images except where shown otherwise, is my copyright. Anyone is permitted to use or adapt any of the code, scripts or images for any purpose, including commercial use.
Anyone is permitted to re-publish this page, but only for non-commercial use.
Anyone is permitted to link to this page, including for commercial use.
Page version v1.0 21-July-2016.
Page created 25-Jul-2016 20:47:04.
Copyright © 2016 Alan Gibson.