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

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

Post 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

Image

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

Image

i expected something like this


Image
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
Image

this is my expected output

Image

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
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 »

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?
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 »

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.
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 »

i use version 7.0 and use linux ubuntu the watermark is the same circle
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 »

try this

Input:
Image

Code: Select all

magick -size 55x55 xc:black -fill white -draw "translate 27,27 circle 0,0 0,27" -alpha off mask.png
Image

Code: Select all

magick mask.png -negate circle.png
Image

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
Image

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
Image


See viewtopic.php?f=4&t=31053 for IM 7 version requirements.
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 »

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.
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 »

hi very thankyou for your response but i think is so very complicated to implement for general purposes
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 »

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.
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 »

I will put an example here what happens that when using my command some watermarks darken and others simply disappear an example here
Image

Image
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 »

and other watermarks certain percentage disappears
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 »

This varies depending on the intensity of the 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 »

My intention is to detect the watermark regardless of its shape or intensity
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 problem is not the complexity of the command but the ability to adapt to different forms
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 »

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
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 »

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
Post Reply