What is the proper command for masking layers?

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?".
Locked
User avatar
yarr
Posts: 17
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151
Location: Poland
Contact:

What is the proper command for masking layers?

Post by yarr »

Hello

I'm having difficulty getting good quality masking layers.

I would like to ask for help in adjusting the syntax.

Below is a preview of the layers and two final results:
the bottom left (masked in After Effects) suits me,
and the right (IM) does not, despite using the same mask.
Image

I also attach a workspace archive with original size rasters
and vector data generated from the shapefile.

I suspect that I should refine creating the mask,
or rather cleansing it, but I can't do it.

The source monochromatic mask (rasterization of vector data) is quite large
and I reduce it by half during conversion to reduce the jagging.
Before this last step I add blur and then sharpen the edges,
but I'm not sure if I do it correctly.

Here's the mask creation command (Windows syntax):

Code: Select all

convert -quiet -size 6400x6400 xc:Black %mask%.tif -compose Over -composite ^
		-transparent Black -blur 0x1.5 -sigmoidal-contrast 20x0% -level 30,100% -resize 50% ^
		png32:%mask%.png
OR grayscale mask

Code: Select all

convert -quiet -size 6400x6400 xc:Black %mask%.tif -compose Over -composite ^
		-blur 0x1.5 -sigmoidal-contrast 20x0% -level 30,100% -resize 50% ^
		%mask%.png
I also use an alternative method of direct conversion of scaled cartographic contour paths
using the MVG format (SHP => CSV => MVG),
but although the mask is a little better and the procedure is faster,
I still can't get a better result in the final composition
made using the following command (simplified a bit):

Code: Select all

convert %raster% %bathy% -mask %mask% -compose Replace -composite final_comp.tif
I would be grateful if you could help me refine this one of my basic working procedures.

I sometimes use applications with a graphical interface for more difficult processing,
but I definitely prefer to work on the ImageMagick library
due to the large size of processed resources
and the need for their good organization.
Unfortunately, I'm probably a little blunt and I'm learning too slowly.

Please, forgive me my rough Googled English & thanks in advance for your attention.
yarr

ImageMagick 7.0.9-27 Q16 x64 2020-02-29
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What is the proper command for masking layers?

Post by snibgo »

The coastlines of nokia.tif and oceanmask.mvg don't match. Perhaps the tide was out when nokia.tif was made, and in when oceanmask.mvg was made.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: What is the proper command for masking layers?

Post by fmw42 »

Where are you using the bumpmap image?

User avatar
yarr
Posts: 17
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151
Location: Poland
Contact:

Re: What is the proper command for masking layers?

Post by yarr »

fmw42 wrote:
2020-03-04T18:28:29-07:00
Where are you using the bumpmap image?
I simplified the command because using bumpmap does not affect the final result.
The full command is:

Code: Select all

convert -quiet %raster% %bumpmap% -compose Bumpmap -composite -level 5,100%,1.7 -modulate 100,120,98 ^
         ( %bathy% -level 10,100%,1.2 ) -mask %mask% -compose Replace -composite %final%
yarr

ImageMagick 7.0.9-27 Q16 x64 2020-02-29
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper

User avatar
yarr
Posts: 17
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151
Location: Poland
Contact:

Re: What is the proper command for masking layers?

Post by yarr »

snibgo wrote:
2020-03-04T17:18:57-07:00
The coastlines of nokia.tif and oceanmask.mvg don't match. Perhaps the tide was out when nokia.tif was made, and in when oceanmask.mvg was made.
I agree, but the difference is not significant. It is not easy to achieve perfect convergence with resources in different cartographic projections.
Besides, it's not watchmaking. I only want to achieve better masking quality.

However, the shoreline quite well matches the composition masked in After Effects:

Image
yarr

ImageMagick 7.0.9-27 Q16 x64 2020-02-29
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: What is the proper command for masking layers?

Post by fmw42 »

try resetting your compose methods and other colorspaces for the modulate

Code: Select all

convert -quiet %raster% %bumpmap% -compose Bumpmap -composite -compose over ^
-level 5,100%,1.7 -set modulate:colorspace XXX -modulate 100,120,98 ^
( %bathy% -level 10,100%,1.2 ) -mask %mask% -compose Replace -composite %final%
try XXX = HSV or HCL or HSL

User avatar
yarr
Posts: 17
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151
Location: Poland
Contact:

Re: What is the proper command for masking layers?

Post by yarr »

fmw42 wrote:
2020-03-05T01:31:02-07:00
try resetting your compose methods and other colorspaces for the modulate
...
try XXX = HSV or HCL or HSL
I don't see any effect of using these options.
yarr

ImageMagick 7.0.9-27 Q16 x64 2020-02-29
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: What is the proper command for masking layers?

Post by fmw42 »

Try

Code: Select all

convert -quiet %raster% %bumpmap% -compose Bumpmap -composite -compose over ^
-level 5,100%,1.7 -define modulate:colorspace=XXX -modulate 100,120,98 ^
( %bathy% -level 10,100%,1.2 ) -mask %mask% -compose Replace -composite %final%

User avatar
yarr
Posts: 17
Joined: 2016-09-05T02:20:25-07:00
Authentication code: 1151
Location: Poland
Contact:

Re: What is the proper command for masking layers?

Post by yarr »

fmw42 wrote:
2020-03-05T10:00:07-07:00
Try

Code: Select all

convert -quiet %raster% %bumpmap% -compose Bumpmap -composite -compose over ^
-level 5,100%,1.7 -define modulate:colorspace=XXX -modulate 100,120,98 ^
( %bathy% -level 10,100%,1.2 ) -mask %mask% -compose Replace -composite %final%
Definition options make no difference. Only type of the mask do.

Image

Unfortunately, this is not the difference I care about.

Another raster, without bumpmap and color correction - masking only:

Image
yarr

ImageMagick 7.0.9-27 Q16 x64 2020-02-29
Windows 7 Professional 64 bit, i7-4790 CPU 3.60 GHz, RAM 32 GB
Cartographic environment: Perl, GDAL, Global Mapper

Locked