Page 2 of 2

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-15T14:17:41-07:00
by fmw42
Your error message are because you did not install the script where your PATH can find it, so the unix command -type does not find the script. But you can ignore that.

Yes, -fx is going to be terribly slow for images more than 500x500 size, which take about 15 sec.

But the script could be made into an IM MagickFilter, that can be compiled. See
http://www.imagemagick.org/script/archi ... hp#filters
http://www.imagemagick.org/script/resources.php#modules
http://www.imagemagick.org/script/comma ... hp#process

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-15T16:18:49-07:00
by fmw42
% a = -2; W = (1./(Z.^a)); % 1/(z^a)
What do your %s mean here. I do not see anything like that in the .jar.

Also 1/(Z^a) for a=-2 is just Z^2.

I already have:

1=-1/z,
2=(z+1/z)/2,
3=z^2,
4=sin(z),
5=cos(z),
6=ln(z),
7=(z+1)/(z-1),
8=1/(4*z^2-1)

which cover many of the expressions in the .jar, except he uses Taylor Expansions.

The only real issue with my script is it is a script and uses -fx. So very slow.

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-15T20:26:00-07:00
by fmw42
One can see that the script computes a more zoomed in part of the Matlab result. Perhaps you can give me a proposal for alternative values for "-g 1,1" to zoom out that both images are better comparable
Unfortunately, I do not know how to relate my script to matlab or other conformal mappings. I would just have to do some trial and error same as you. Also you did not say which expression.

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-15T20:28:02-07:00
by fmw42
P.S. I just fixed a bug in -g to allow the comma. I had forgot to allow the comma in my earlier code.

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-15T20:42:03-07:00
by fmw42
You might also find Python based solutions. See
https://pypi.python.org/pypi/cmtoolkit/0.0.1

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-15T20:58:59-07:00
by fmw42
Another possibility is to convert my fx expressions to a 2D displacement map for the conformal map and use -compose distort. See http://www.imagemagick.org/Usage/mappin ... e_displace
http://www.imagemagick.org/script/compose.php

I may experiment with that tomorrow, if I have time.

Re: morphology operation that generate an additional compact border region around shapes

Posted: 2017-02-16T16:44:08-07:00
by fmw42
I have implemented my -1/Z formula to use -compose distort, which is faster (3 sec) vs. my script using -fx (17 sec). But unfortunately -virtual-pixel tile does not work as well in -compose distort. Nevertheless, here is my code. It also needs hdri.

Input:
Image

My conformal script result for -f 1 -g 2:

Code: Select all

conformal -f 1 -g 2 -v tile obama_portrait.jpg obama_portrait_conformal_d_f1_g2_vptile_bblack_zblack.jpg
Image


Using -compose distort:

Code: Select all

declare `convert -ping obama_portrait.jpg -format "ww=%w\nhh=%h\n" info:`
ww2=`convert xc: -format "%[fx:($ww-1)/2]" info:`
hh2=`convert xc: -format "%[fx:($hh-1)/2]" info:`

im6974hdri convert -size ${ww}x${hh} xc: -fx "(i-$ww2)/$ww2" tmpX.mpc

im6974hdri convert -size ${ww}x${hh} xc: -fx "(j-$hh2)/$hh2" tmpY.mpc

im6974hdri convert \
\( tmpX.mpc tmpX.mpc -define compose:clamp=off -compose multiply -composite \) \
\( tmpY.mpc tmpY.mpc -define compose:clamp=off -compose multiply -composite \) \
-define compose:clamp=off -compose plus -composite tmpR2.mpc


im6974hdri convert tmpX.mpc tmpR2.mpc +swap \
-define compose:clamp=off -compose divide -composite \
-evaluate multiply -0.25 -evaluate add 50% \
tmpXR2.mpc

im6974hdri convert tmpY.mpc tmpR2.mpc +swap \
-define compose:clamp=off -compose divide -composite \
-evaluate multiply 0.25 -evaluate add 50% \
tmpYR2.mpc

im6974hdri convert obama_portrait.jpg tmpXR2.mpc tmpYR2.mpc \
-virtual-pixel tile -define compose:args="200%x200%" \
-compose distort -composite obama_portrait_conformal_distort_f1_g2_vptile.jpg
Image

My code could be made more efficient by combining all the steps into one command line. But this was just a test. Since the -virtual-pixel tile does not work adequately, there seems no point in going further with this approach.