How i apply a mask to a grayscale image ?
How i apply a mask to a grayscale image ?
Hi,
I want apply a mask to an image. (image and mask have the same dimensions)
input.png (grayscale)
mask.png
I used the next code:
convert input.png mask.png -alpha off -compare CopyOpacity -composite out.png
The mask was applied correctly, but the out.png lost the grayscale (obviously), i think..
Suggestions for applying the mask and not lose the grayscale ?
thanks
I want apply a mask to an image. (image and mask have the same dimensions)
input.png (grayscale)
mask.png
I used the next code:
convert input.png mask.png -alpha off -compare CopyOpacity -composite out.png
The mask was applied correctly, but the out.png lost the grayscale (obviously), i think..
Suggestions for applying the mask and not lose the grayscale ?
thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How i apply a mask to a grayscale image ?
Use "-compose" instead of "-compare":
If that doesn't help, upload inputs and output to somewhere like dropbox.com and paste the URLs here.
Code: Select all
convert input.png mask.png -alpha off -compose CopyOpacity -composite out.png
snibgo's IM pages: im.snibgo.com
Re: How i apply a mask to a grayscale image ?
The same :/
Mask image:
Input image:
Mask image:
Input image:
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How i apply a mask to a grayscale image ?
Code: Select all
convert 2z4er1s.png 14j5cmw.png -alpha off -compose CopyOpacity -composite outMasked.png
It looks fine to me. What result do you get? What is wrong with it?
snibgo's IM pages: im.snibgo.com
Re: How i apply a mask to a grayscale image ?
yes, it looks fine.. Sorry, bad example :/
With the next images, you can see the differences.
input:
mask:
Thanks
With the next images, you can see the differences.
input:
mask:
Thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How i apply a mask to a grayscale image ?
Again, the result looks fine to me. What is wrong with it?
Code: Select all
convert elcqxy.jpg.png 2ueigev.jpg.png -alpha off -compose CopyOpacity -composite outMasked2.png
snibgo's IM pages: im.snibgo.com
Re: How i apply a mask to a grayscale image ?
My result:
My code:
Why is different?
Thanks
My code:
Code: Select all
convert input2.png mask2.png -alpha off -compose CopyOpacity -composite outMasked_2.png
Thanks
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How i apply a mask to a grayscale image ?
What version of IM and platform are you using?
Nothing is wrong with it. Your two examples are on different color backgrounds, which show through in the transparent areas.
Nothing is wrong with it. Your two examples are on different color backgrounds, which show through in the transparent areas.
Re: How i apply a mask to a grayscale image ?
Version: ImageMagick 6.7.7-10 2014-03-06
Platform: Linux - Ubuntu
Thanks
Platform: Linux - Ubuntu
Thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How i apply a mask to a grayscale image ?
Your result is darker than mine, because your old version of ImageMagick 6.7.7-10 was confused between linear and non-linear grayscale. I suggest you upgrade to a recent version.
snibgo's IM pages: im.snibgo.com
Re: How i apply a mask to a grayscale image ?
Yes, I update ImageMagick to a recent version and solved my problem.
Thanks
Thanks