how i could make better this command for detect a transparent watermark?

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?".
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could make better this command for detect a transparent watermark?

Post by diegomage »

The command that I publish is useful for detect 60% to 80% of watermark sometimes works perfectly with a hight intensity watermark
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could make better this command for detect a transparent watermark?

Post by diegomage »

Adding more information to the post I would like to ask you another question for example in this image

Image

this command output
coords=$( compare -metric rmse -subimage-search -dissimilarity-threshold 1 dIsuln3.png \( -read-mask mask.png circle.png \) null: 2>&1 | cut -d@ -f2 | sed 's/ *//g')
xoff=$(echo $coords | cut -d, -f1)
yoff=$(echo $coords | cut -d, -f2)
magick \( dIsuln3.png -crop 55x55+${xoff}+${yoff} +repage \) mask.png -alpha off -compose copy_opacity -composite watermark2.png

this

Image

but using this command

convert -negate dIsuln3.png dIsuln4.png
convert dIsuln4.png -level 10%,80 dIsuln5.png
convert -noise 20x20 dIsuln5.png dIsuln6.png
convert dIsuln6.png +dither -posterize 2 mono1g2.png


output this

Image

how i could doing better with the first command
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could make better this command for detect a transparent watermark?

Post by diegomage »

Adding more information to the post I would like to ask you another question for example in this image

Image

this command output
coords=$( compare -metric rmse -subimage-search -dissimilarity-threshold 1 dIsuln3.png \( -read-mask mask.png circle.png \) null: 2>&1 | cut -d@ -f2 | sed 's/ *//g')
xoff=$(echo $coords | cut -d, -f1)
yoff=$(echo $coords | cut -d, -f2)
magick \( dIsuln3.png -crop 55x55+${xoff}+${yoff} +repage \) mask.png -alpha off -compose copy_opacity -composite watermark2.png

this

Image

Image
but using this command

convert -negate dIsuln3.png dIsuln4.png
convert dIsuln4.png -level 10%,80 dIsuln5.png
convert -noise 20x20 dIsuln5.png dIsuln6.png
convert dIsuln6.png +dither -posterize 2 mono1g2.png


output this

Image
Image

how i could doing better with the first command
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could make better this command for detect a transparent watermark?

Post by diegomage »

Adding more information to the post I would like to ask you another question for example in this image

Image

this command output
coords=$( compare -metric rmse -subimage-search -dissimilarity-threshold 1 dIsuln3.png \( -read-mask mask.png circle.png \) null: 2>&1 | cut -d@ -f2 | sed 's/ *//g')
xoff=$(echo $coords | cut -d, -f1)
yoff=$(echo $coords | cut -d, -f2)
magick \( dIsuln3.png -crop 55x55+${xoff}+${yoff} +repage \) mask.png -alpha off -compose copy_opacity -composite watermark2.png

this

Image

Image
but using this command

convert -negate dIsuln3.png dIsuln4.png
convert dIsuln4.png -level 10%,80 dIsuln5.png
convert -noise 20x20 dIsuln5.png dIsuln6.png
convert dIsuln6.png +dither -posterize 2 mono1g2.png


output this

Image
Image

how i could doing better with the first command
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how i could make better this command for detect a transparent watermark?

Post by fmw42 »

When the foreground and background are too similar, the compare method does not work well. However, if you use an actual watermark from your other image, that seems to work.

Image:
Image

Watermark Image:
Image

Mask Image:
Image

Code: Select all

coords=$( magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 hTSox.png \( -read-mask mask.png watermark2.png \) null: 2>&1 | cut -d@ -f2 | sed 's/ *//g')
xoff=$(echo $coords | cut -d, -f1)
yoff=$(echo $coords | cut -d, -f2)
magick \( hTSox.png -crop 55x55+${xoff}+${yoff} +repage \) mask.png -alpha off -compose copy_opacity -composite watermark3.png
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how i could make better this command for detect a transparent watermark?

Post by fmw42 »

Sorry, I edited my post to remove my special scripting code "im7" that allows me to run different versions of IM on my Mac.
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could make better this command for detect a transparent watermark?

Post by diegomage »

ok very thank you for your response; I am very grateful
Post Reply