Original Image:
and this what needs to be achieved.
brick image:
I have many images like one below
I need to multiply this image with a color say "rgba(103,68,56,5)" and make the center white part transparent.
The way I do:
convert mortar.png ( -clone 0 -fill 'rgba(103,68,56,5)' -colorize 100 ) -channel rgba -alpha on -compose Multiply -composite mortar.png
convert mortar.png -transparent 'rgba(103,68,56,5)' mortar.png
the resultant image I get is:
Where as desired image is something like one below: Just look at the inside corner line of the image and the dots on white area you can ignore.
I have tried with different fuzz values as well but that degrades the image more and put holes in the colored area.
Please right click the image and save it at your location to see what full image looks like.
Output after adding blur with command
convert m.png -blur 0x.3 ( +clone -fill 'rgba(103,68,56,5)' -colorize 100 ) -channel rgba -alpha on -compose Multiply -composite -transparent 'rgba(103,68,56,5)' out.png
Desired output:
Updated Answer
I think the problem is that your original mortar image is already noisy around the borders. I took it into Photoshop and enlarged it a lot and you can see that it has noisy artefacts around the edges.
I can only think of blurring these and then thresholding them up to pure white, because some of the noisy bits actually also occur in the real borders where you don't want them to go transparent. I am thinking along these lines:
Not sure what else to suggest.
Original Answer
I think you might find it useful to add a tiny amount of blur to help the edges, and also do it all in one go like this: