And please whats next step? How to merge function compare and convert together ?
They really cannot be merged. You can pipe the results from convert to compare, but this is really not much different that using two separate commands. It just allow you to avoid saving an image.
If your patch is not the same size for each image, then you need to use different size patches for each image, or use the smallest patch size from all the images (assuming it is reasonably large enough for all images). If you can be assured that the color of the patch is unique for all images -- there is no near color in any image -- then you can even use a 1 pixel patch. Then optionally in compare add -similarity-threshold 0 for -metric rmse and it will stop at the first pixel that is a perfect match (for versions 6.8.3-10 or higher). Get the coordinates from the compare and use those to composite your text image at that coordinate.
Here is a simple example:
Input image has red pixel near the center:
Create text image:
convert -size 20x -background white -fill black label:"A" 1A.png
Do compare, get coordinates as variable in form x+y
coords=`compare -metric rmse -subimage-search -similarity-threshold 0 cyclops1.png -size 1x1 xc:red null: 2>&1 |\
cut -d\ -f4 | tr "," "+"`
echo $coords
49+49
Composite the text image over the background image
convert cyclops1.png 1A.png -geometry "+$coords" -compose over -composite cyclops1_label.png
