IM masking question on black transforms

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
jonnabu4
Posts: 2
Joined: 2017-01-23T05:44:47-07:00
Authentication code: 1151

IM masking question on black transforms

Post by jonnabu4 »

Hello,

I am an imagemagick rookie, and I am trying to apply a mask on a black n white photo, so in the end, I have black of the photo turned to transparent.

I am transforming #000000 to #010101 for the original image to begin with, but when, after applying the mask I am turning all true black to transparent, I need to use a fuzz factor of 3%. And that again creates transparency in my photo obviously.

Is there something else I can do other than setting fuzz to 0% or turning the original true black to an even lighter gray?

Here is my script now:

convert ${previousline} -fill '#010101' -opaque '#000000' -scale 620x380+0+0 ${targetfile}
convert ${template-pic-mask_local} ${previousline} -geometry +48+52 ${template-pic-mask_local} -compose multiply -composite ${targetfile}
convert ${previousline} -fuzz 3% -transparent '#000000' ${targetfile}
convert ${template-pic-main_local} ${previousline} -geometry +241+25 -composite ${targetfile}

Any help will be very much appreciated! Thank you in advance :)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM masking question on black transforms

Post by snibgo »

You have four convert commands. They all create or re-create ${targetfile}. So the first three have zero effect.

I don't understand what you want to do. Perhaps you want to make all black pixels transparent, and leave all the others untouched. If so, then:

Code: Select all

convert in.png -transparent Black out.png
snibgo's IM pages: im.snibgo.com
jonnabu4
Posts: 2
Joined: 2017-01-23T05:44:47-07:00
Authentication code: 1151

Re: IM masking question on black transforms

Post by jonnabu4 »

I forgot to mention that {$previousline} always dynamically get the result of each previous command's {$targetfile}.
So I can see that the first four commands are working.
The biggest issue is that fuzz takes along non-true black pixels, pixels of the original photo. While the mask needs the fuzz factor to be applied smoothly. :)

I hope this helps into understanding the issue. :)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM masking question on black transforms

Post by snibgo »

So each ${previousline} is the previous command's ${targetfile}? That makes debugging "interesting". Why not use just one command? Any other weird rules we need to know about?

Sorry, I still don't know what you are trying to do. If you supplied your input files, that might help.
snibgo's IM pages: im.snibgo.com
Post Reply