Page 1 of 2
how i could make better this command for detect a transparent watermark?
Posted: 2017-03-08T13:23:12-07:00
by diegomage
I have a simple command for detect a transparent watermark transform the watermark to black but this command fail detect the circle but with a extra space
convert -noise 20x20 resultnn.png output.jpg
convert output.jpg +dither -posterize 2 mono12.png
how i could do this better
this is my output
i expected something like this
enter image description here
what I could do
doing a crop i obtain this
convert mono12.png -fuzz 10% -fill blue +opaque "#000000" monod12.png
corde=$(convert monod12.png -median 3x3 -format %@ info:)
convert resultnn.png -crop $corde +repage resulnmonod12.png
this is my expected output
i need detect the circle ; I would use a command to detect it by color; But as it is a transparent watermark this is impossible
Please help me
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-08T13:58:42-07:00
by fmw42
What is your IM version and platform? Please always provide that.
Is your watermark always the same size circle? Do you have more than one image with the same watermark?
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-08T14:05:13-07:00
by fmw42
If the watermark is always the same size circle, then you could make a black circle image and do a subimage compare to locate its coordinates and then crop accordingly.
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-08T14:14:05-07:00
by diegomage
i use version 7.0 and use linux ubuntu the watermark is the same circle
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-08T15:27:01-07:00
by fmw42
try this
Input:
Code: Select all
magick -size 55x55 xc:black -fill white -draw "translate 27,27 circle 0,0 0,27" -alpha off mask.png
Code: Select all
magick mask.png -negate circle.png
Code: Select all
coords=`magick compare -metric rmse -subimage-search -dissimilarity-threshold 1 \
dIsul.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 dIsul.png -crop 55x55+${xoff}+${yoff} +repage watermark.png
Or replace the last line with
Code: Select all
magick \( dIsul.png -crop 55x55+${xoff}+${yoff} +repage \) mask.png \
-alpha off -compose copy_opacity -composite watermark2.png
See
viewtopic.php?f=4&t=31053 for IM 7 version requirements.
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-08T18:55:02-07:00
by fmw42
I have moved this post from Developers to Users forum and deleted your duplicate post in the Users forum. Please do not post to multiple forums.
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T15:11:18-07:00
by diegomage
hi very thankyou for your response but i think is so very complicated to implement for general purposes
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T16:22:06-07:00
by fmw42
You said all your images had the same watermark circle size and shape. So why is that hard to implement? Also, he first two lines can be combined into one command.
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T17:14:50-07:00
by diegomage
I will put an example here what happens that when using my command some watermarks darken and others simply disappear an example here
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T17:15:32-07:00
by diegomage
and other watermarks certain percentage disappears
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T17:16:17-07:00
by diegomage
This varies depending on the intensity of the watermark
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T17:17:14-07:00
by diegomage
My intention is to detect the watermark regardless of its shape or intensity
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T17:18:11-07:00
by diegomage
The problem is not the complexity of the command but the ability to adapt to different forms
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T18:24:39-07:00
by fmw42
It is almost impossible to extract any arbitrary watermark, unless you have multiple images with the same watermark that have the watermark in the same location and the background of all the images are different. At least I know of no way.
If you have two images, then see
viewtopic.php?f=1&t=31126&p=141311&hili ... cy#p141311
Re: how i could make better this command for detect a transparent watermark?
Posted: 2017-03-09T18:45:58-07:00
by diegomage
I want to clarify that your command helped me a lot and I am very grateful for your answer only that I wanted to get something more general however that command helped me a lot
I think summarizing this post
The command that I publish could be useful to detect a point contained in the watermark
The command you posted is useful for detecting a constant watermark