How to erase shoreline but preserve admin land borders?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to erase shoreline but preserve admin land borders?

Post by Bonzo »

I have just run fmw42's last code above on a Windows 10 PC with a V7.05 Q16 install and get the same results as fmw42.

Still using convert, changing the \ to ^ and removing the \ from the parentheses.
Last edited by Bonzo on 2017-06-23T13:36:11-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to erase shoreline but preserve admin land borders?

Post by fmw42 »

With my code, you must use Cygwin or change the code to Windows equivalent syntax. Perhaps your Cygwin version of ImageMagick is too old? Connected Components Labelling requires IM 6.8.9.10 or higher. But some features were added later regarding mean-color=true. The latest changelog for connected components is 6.9.6-8, but I think the following should work earlier than that.

In Windows CMD window (not .bat), try

Code: Select all

convert admin_borders.png ^
( oceanmask.png -blur 0x5 -level 99,100% ) -compose In -composite ^
admin_borders_choked.png

convert admin_borders_choked.png -alpha off -threshold 0 ^
-define connected-components:area-threshold=75 ^
-define connected-components:mean-color=true ^
-connected-components 8 ^
admin_borders_clean.png

convert admin_borders_choked.png -alpha off -threshold 0 ^
-define connected-components:area-threshold=75 ^
-define connected-components:mean-color=true ^
-connected-components 8 -transparent black ^
admin_borders_clean_trans.png
yarr
Posts: 12
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151

Re: How to erase shoreline but preserve admin land borders?

Post by yarr »

I reinstalled my Windows IM.
Both commands work:

Code: Select all

convert admin_borders.png ^
	( oceanmask.png -blur 0x5 -level 99,100%% ) -compose In -composite ^
	admin_borders_choked.png

convert admin_borders_choked.png -alpha off -threshold 0 ^
	-define connected-components:area-threshold=75 ^
	-define connected-components:mean-color=true ^
	-connected-components 8 ^
	admin_borders_clean.png

convert admin_borders_choked.png -alpha off -threshold 0 ^
	-define connected-components:area-threshold=75 ^
	-define connected-components:mean-color=true ^
	-connected-components 8 -transparent black ^
	admin_borders_clean_trans.png
Thank you.

yarr
yarr

ImageMagick 7.0.6-0 Q16 x64 2017-06-11
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper
yarr
Posts: 12
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151

Re: How to erase shoreline but preserve admin land borders?

Post by yarr »

After upgrading IM I noticed meaningful difference in my other composites rendered previously as I expected.

ImageMagick 6.9.2-0 Q16 x64 2015-08-15
Image

ImageMagick 7.0.6-0 Q16 x64 2017-06-11
Image

Can you please help me find the reason of this difference and correct the syntax?

Code: Select all

convert -quiet ^
	( ^
		( ^
			blueyahoo.tif ( bumpmap.tif -blur 0x1 ) ^
			-level 5%%,100,3 -modulate 100,120,102 -compose bumpmap -composite ^
			landwater.png -compose Over -composite ^
		) ^
		oceanmask.png -mask oceanmask.png -compose Copy -composite ^
	) ^
	bathy.tif -mask oceanmask.png -compose Over -composite ^
	-compress lzw ^
	blueyahoo_composite.tif

yarr

ImageMagick 7.0.6-0 Q16 x64 2017-06-11
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper
yarr
Posts: 12
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151

Re: How to erase shoreline but preserve admin land borders?

Post by yarr »

All right, I found the solution: removing unnecessary line

Code: Select all

		oceanmask.png -mask oceanmask.png -compose Copy -composite ^
But please tell me if the code could be smarter.
yarr

ImageMagick 7.0.6-0 Q16 x64 2017-06-11
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to erase shoreline but preserve admin land borders?

Post by fmw42 »

In IM 7, use "magick" not "convert" (without the quotes)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to erase shoreline but preserve admin land borders?

Post by fmw42 »

In IM 7 Windows CMD window, this should work.

Code: Select all

magick admin_borders.png ^
( oceanmask.png -blur 0x5 -level 99,100% ) -compose In -composite ^
admin_borders_choked.png

magick admin_borders_choked.png -alpha off -threshold 0 ^
-define connected-components:area-threshold=75 ^
-define connected-components:mean-color=true ^
-connected-components 8 ^
admin_borders_clean.png

magick admin_borders_choked.png -alpha off -threshold 0 ^
-define connected-components:area-threshold=75 ^
-define connected-components:mean-color=true ^
-connected-components 8 -transparent black ^
admin_borders_clean_trans.png
Post Reply