Multiply image anti-aliasing problem
Multiply image anti-aliasing problem
Please have a look at this question http://stackoverflow.com/questions/2709 ... i-aliasing
Need help urgent.
Need help urgent.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
try the following (unix syntax):
If you want to anti-alias the boundary, then try this
Code: Select all
convert c5VyQ.png -morphology open octagon:3 \
-fuzz 10% -transparent white \
-fill "rgba(103,68,56,5)" +opaque none \
result.png
If you want to anti-alias the boundary, then try this
Code: Select all
convert c5VyQ.png -morphology open octagon:3 \
-fuzz 10% -transparent white \
-background "rgba(103,68,56,5)" -alpha background \
-fill "rgba(103,68,56,5)" +opaque none \
\( -clone 0 -alpha extract -blur 0x2 -level 50x100% \) \
-alpha off -compose copy_opacity -composite \
result2.png
Re: Multiply image anti-aliasing problem
This is not the desired result. The flow required is as shown in the image, can you please have a look at it? and suggest right approach.
orignal alpha image of the mortar I have is:

Original brick image I have is.

My imagemagick version is Version: ImageMagick 6.5.4-7 2014-02-10 Q16.

orignal alpha image of the mortar I have is:

Original brick image I have is.

My imagemagick version is Version: ImageMagick 6.5.4-7 2014-02-10 Q16.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
Please provide all the components as separate image at the same scale. This includes the material image, the gray brick image and if you have a mask, then provide that. If the mask is created from the material image, then let us know that.
It looks line you want to take the material image, extract one row, then make a mask for the border, then put the gray brick image in the border, then recolor the gray brick image. Is that correct? If not, then please describe in more detail what you want. It is hard to know from just your diagrams.
The material image and the gray brick pattern seem to be the key image and you did not provide either previously and still not the material image for filling the inside areas.
If you provide one question that does not explain your real issue and then we reply and you change the problem, then that is very confusing.
It looks line you want to take the material image, extract one row, then make a mask for the border, then put the gray brick image in the border, then recolor the gray brick image. Is that correct? If not, then please describe in more detail what you want. It is hard to know from just your diagrams.
The material image and the gray brick pattern seem to be the key image and you did not provide either previously and still not the material image for filling the inside areas.
If you provide one question that does not explain your real issue and then we reply and you change the problem, then that is very confusing.
Re: Multiply image anti-aliasing problem
It looks line you want to take the material image, extract one row, then make a mask for the border, then put the gray brick image in the border, then recolor the gray brick image. Is that correct?
Yes, this is correct and that is all I have as Input.
I multiply different RGBA values into that grey area of the image for example (103,68,56,5).
The material image is

Yes, this is correct and that is all I have as Input.
I multiply different RGBA values into that grey area of the image for example (103,68,56,5).
The material image is

- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
How can anyone do what you suggest by your diagrams without the red brick pattern? I am very confused. What should the final image look like? What about the border image and also the interior red brick image.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Multiply image anti-aliasing problem
Maybe it works like this. I take the top third of 4Biet.png as a mask for bricks/mortar, and the middle third as texture for mortar. Windows BAT script:
I have ignored the bottom third of 4Biet.png, and cropped the output.

EDIT: "+write bf.png" and "+write bb.png" are just to show what is happening, and to help you adjust the two colours to your taste.
Code: Select all
convert ^
4Biet.png ^
-crop 1x3@ +repage ^
b.png
convert ^
( b-1.png -fill rgb(100%%,75%%,30%%) -colorize 50 +write bf.png ) ^
( pK1xB.jpg -fill rgb(100%%,40%%,30%%) -colorize 50 +write bb.png ) ^
b-0.png ^
-composite ^
-gravity center -crop 1000x+0+0 +repage ^
bricks.png

EDIT: "+write bf.png" and "+write bb.png" are just to show what is happening, and to help you adjust the two colours to your taste.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
I also want to point out that there is no such color as "rgba(103,68,56,5)". Alpha values are specified in the range 0 to 1. So I am not sure whether you meant alpha=0.5 or were trying to get alpha as 5/255 = 0.02
Furthermore, you did not say why my two sets of code did not satisfy the example from the link you mentioned. Without some good feedback we do not know what you are trying to do and can only guess as user snibgo tried to do.
Furthermore, you did not say why my two sets of code did not satisfy the example from the link you mentioned. Without some good feedback we do not know what you are trying to do and can only guess as user snibgo tried to do.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
Here is an alternate attempt to guess what you want.
unix syntax
I left the -write show: in so you can see each step

The above colorizes the grout/mortar area (actually the whole first image c5VyQ.png) with #B6977A (taken from your diagram). Then it creates a mask. Then it composites the gray texture image you provided pK1xB.jpg with the colorized image using the mask, so the gray texture is in the center and colorized grout/mortar region is outside.
Here are some alternates where I tried to colorize the gray texture image with the red brick color you specified.
# use +level-colors to colorize

# use -colorize 85% to colorize

# use -colorize 90% to colorize

unix syntax
I left the -write show: in so you can see each step
Code: Select all
convert c5VyQ.png pK1xB.jpg \
\( -clone 0 +level-colors "black,#B6977A" -write show: \) \
\( -clone 0 -morphology open octagon:3 \
-fuzz 10% -transparent white -channel rgba \
-fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \
-blur 0x2 -level 0x50% -write show: \) \
-delete 0 -compose over -composite result.jpg

The above colorizes the grout/mortar area (actually the whole first image c5VyQ.png) with #B6977A (taken from your diagram). Then it creates a mask. Then it composites the gray texture image you provided pK1xB.jpg with the colorized image using the mask, so the gray texture is in the center and colorized grout/mortar region is outside.
Here are some alternates where I tried to colorize the gray texture image with the red brick color you specified.
# use +level-colors to colorize
Code: Select all
convert c5VyQ.png \( pK1xB.jpg +level-colors "black,rgb(103,68,56)" -write show: \) \
\( -clone 0 +level-colors "black,#B6977A" -write show: \) \
\( -clone 0 -morphology open octagon:3 \
-fuzz 10% -transparent white -channel rgba \
-fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \
-blur 0x2 -level 0x50% -write show: \) \
-delete 0 -compose over -composite result2.jpg

# use -colorize 85% to colorize
Code: Select all
convert c5VyQ.png \( pK1xB.jpg -colorspace gray -fill "rgb(103,68,56)" -colorize 85% -write show: \) \
\( -clone 0 +level-colors "black,#B6977A" -write show: \) \
\( -clone 0 -morphology open octagon:3 \
-fuzz 10% -transparent white -channel rgba \
-fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \
-blur 0x2 -level 0x50% -write show: \) \
-delete 0 -compose over -composite result3.jpg

# use -colorize 90% to colorize
Code: Select all
convert c5VyQ.png \( pK1xB.jpg -colorspace gray -fill "rgb(103,68,56)" -colorize 90% -write show: \) \
\( -clone 0 +level-colors "black,#B6977A" -write show: \) \
\( -clone 0 -morphology open octagon:3 \
-fuzz 10% -transparent white -channel rgba \
-fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \
-blur 0x2 -level 0x50% -write show: \) \
-delete 0 -compose over -composite result4.jpg

Re: Multiply image anti-aliasing problem
fmw42 wrote:Here is an alternate attempt to guess what you want.
unix syntax
I left the -write show: in so you can see each step
Code: Select all
convert c5VyQ.png pK1xB.jpg \ \( -clone 0 +level-colors "black,#B6977A" -write show: \) \ \( -clone 0 -morphology open octagon:3 \ -fuzz 10% -transparent white -channel rgba \ -fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \ -blur 0x2 -level 0x50% -write show: \) \ -delete 0 -compose over -composite result.jpg
The above colorizes the grout/mortar area (actually the whole first image c5VyQ.png) with #B6977A (taken from your diagram). Then it creates a mask. Then it composites the gray texture image you provided pK1xB.jpg with the colorized image using the mask, so the gray texture is in the center and colorized grout/mortar region is outside.
Here are some alternates where I tried to colorize the gray texture image with the red brick color you specified.
# use +level-colors to colorizeCode: Select all
convert c5VyQ.png \( pK1xB.jpg +level-colors "black,rgb(103,68,56)" -write show: \) \ \( -clone 0 +level-colors "black,#B6977A" -write show: \) \ \( -clone 0 -morphology open octagon:3 \ -fuzz 10% -transparent white -channel rgba \ -fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \ -blur 0x2 -level 0x50% -write show: \) \ -delete 0 -compose over -composite result2.jpg
# use -colorize 85% to colorizeCode: Select all
convert c5VyQ.png \( pK1xB.jpg -colorspace gray -fill "rgb(103,68,56)" -colorize 85% -write show: \) \ \( -clone 0 +level-colors "black,#B6977A" -write show: \) \ \( -clone 0 -morphology open octagon:3 \ -fuzz 10% -transparent white -channel rgba \ -fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \ -blur 0x2 -level 0x50% -write show: \) \ -delete 0 -compose over -composite result3.jpg
# use -colorize 90% to colorizeCode: Select all
convert c5VyQ.png \( pK1xB.jpg -colorspace gray -fill "rgb(103,68,56)" -colorize 90% -write show: \) \ \( -clone 0 +level-colors "black,#B6977A" -write show: \) \ \( -clone 0 -morphology open octagon:3 \ -fuzz 10% -transparent white -channel rgba \ -fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \ -blur 0x2 -level 0x50% -write show: \) \ -delete 0 -compose over -composite result4.jpg
I am sorry for being not so clear in my question. The fist image very close to what I need:


this is the kind of result is needed. Also we need to make that material part transparent in the final image so that different materials can fit in the background. Thank you a lot for all the effort you have put in.
the material used in actual output is:

the mortar is:

Last edited by nagarwal on 2014-11-25T23:11:06-07:00, edited 1 time in total.
Re: Multiply image anti-aliasing problem
this is close to the result I needed but it has some blur in it. can we make the material part transparent so that different materials can be fit in the background on the fly?snibgo wrote:Maybe it works like this. I take the top third of 4Biet.png as a mask for bricks/mortar, and the middle third as texture for mortar. Windows BAT script:I have ignored the bottom third of 4Biet.png, and cropped the output.Code: Select all
convert ^ 4Biet.png ^ -crop 1x3@ +repage ^ b.png convert ^ ( b-1.png -fill rgb(100%%,75%%,30%%) -colorize 50 +write bf.png ) ^ ( pK1xB.jpg -fill rgb(100%%,40%%,30%%) -colorize 50 +write bb.png ) ^ b-0.png ^ -composite ^ -gravity center -crop 1000x+0+0 +repage ^ bricks.png
EDIT: "+write bf.png" and "+write bb.png" are just to show what is happening, and to help you adjust the two colours to your taste.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
Blur was only used to anti-alias the edges of the mask image. If you do not want it, just remove the -blur -level

That is the best I can do to help. Sorry, but you keep changing the images and it is getting very confusing and frustrating. If you want to do it to a different image, this should be all you need.
Code: Select all
convert c5VyQ.png pK1xB.jpg \
\( -clone 0 +level-colors "black,#B6977A" -write show: \) \
\( -clone 0 -morphology open octagon:3 \
-fuzz 10% -transparent white -channel rgba \
-fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \) \
-delete 0 -compose over -composite result5.jpg

That is the best I can do to help. Sorry, but you keep changing the images and it is getting very confusing and frustrating. If you want to do it to a different image, this should be all you need.
Re: Multiply image anti-aliasing problem
I am really sorry about that, but these are just different kind of mortar and material image and luckily your solution works for all the mortars and materials. Thanks for all the help, I appreciate all your efforts. Please help with one last thing. I need to set the material part transparent in the final image .fmw42 wrote:Blur was only used to anti-alias the edges of the mask image. If you do not want it, just remove the -blur -level
Code: Select all
convert c5VyQ.png pK1xB.jpg \ \( -clone 0 +level-colors "black,#B6977A" -write show: \) \ \( -clone 0 -morphology open octagon:3 \ -fuzz 10% -transparent white -channel rgba \ -fill "rgba(255,255,255,1)" +opaque none -fill "rgba(0,0,0,1)" -opaque none -write show: \) \ -delete 0 -compose over -composite result5.jpg
That is the best I can do to help. Sorry, but you keep changing the images and it is getting very confusing and frustrating. If you want to do it to a different image, this should be all you need.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Multiply image anti-aliasing problem
How can my result and snibgo's both be what you want. They are totally different. I did not recolor the gray texture in the middle parts in the example you said you liked (my others were recolored). At the same time you say snigbo's is what you want and his is recolored.
Re: Multiply image anti-aliasing problem
I was looking at the resultant output and If you see the both the output and the resultant output neededfmw42 wrote:How can my result and snibgo's both be what you want. They are totally different. I did not recolor the gray texture in the middle parts in the example you said you liked (my others were recolored). At the same time you say snigbo's is what you want and his is recolored.
