Page 1 of 1

Combine two pictures in one

Posted: 2011-05-01T10:35:00-07:00
by ghostmansd
Dear forum users, I have two images of the same size: first one is monochrome ($TEXT), and the second one is full color ($PICS). I need to perform following operations:
1. Replace all black and white pixels in $PICS to transparent.
2. Replace all white pixels in $TEXT to transparent.
3. Make a new file $OUTPUT with the same size and white background.
4. Insert to all data from $PICS and $TEXT, saving transparency.
5. Delete all files, excluding $OUTPUT.

Re: Combine two pictures in one

Posted: 2011-05-01T12:09:27-07:00
by fmw42
can you post a link to your two images (or samples like them) and a resulting image?

What platform and version of IM are you using?

Have you read viewtopic.php?f=1&t=9620?

Re: Combine two pictures in one

Posted: 2011-05-01T12:52:16-07:00
by ghostmansd
I have no samples, only idea. This script will be used for combining black-white text and colored pictures. After scanning user receives two pictures: one is black-white and another one is colored with deleted text. This is the best way to make good scans for djvu documents, which is called "separated scans".

Re: Combine two pictures in one

Posted: 2011-05-01T13:25:08-07:00
by fmw42
I am not sure I understand fully your request, but here is a try.

#Create text image:
convert -size 320x240 -background white -gravity center -font Arial -fill black caption:"THIS IS A TEXT IMAGE" text.png

#Create logo image:
convert logo: -resize 50% logo2.png

#Process to make transparent and then overlay with a white background
convert \( logo2.png -fuzz 0% -transparent white -transparent black \) \
\( text.png -fuzz 0% -transparent white \) \
-background white -flatten logo_text.png

Note I have included a -fuzz 0% which means that only perfectly black and white will become transparent. But if you change it to some non-zero value then you will make close to white or black also transparent to avoid any halo effects from antialiasing due to resizing or from creating the text.

see http://www.imagemagick.org/Usage/layers/#flatten

Re: Combine two pictures in one

Posted: 2011-05-02T05:54:09-07:00
by ghostmansd
fmw42 wrote:I am not sure I understand fully your request, but here is a try.
Yes, that is directly what I need.
Anthony, could you explain, please? Or provide an example.

Re: Combine two pictures in one

Posted: 2011-05-02T13:05:08-07:00
by ghostmansd
I think Fred's MagicWand would be perfect tool. Procedure, I think, is not very hard.

App selects white and near-white pixels with MagicWand and makes them white, excluding white and almost-white in pictures. This means that MagicWand should select only neighbor white pixels, with sensitivity about 25%. Is it possible? I've smoked MagicWand manuals, but I didn't find a way to select only neighbor pixels.

And that, of course, doesn't solve another problem: app must understand, where the text begins, and where to begin selection.

Re: Combine two pictures in one

Posted: 2011-05-04T13:29:35-07:00
by ghostmansd
Is anybody here? :-)

Re: Combine two pictures in one

Posted: 2011-05-04T14:39:00-07:00
by fmw42
ghostmansd wrote:Is anybody here? :-)

What is the question? I thought your original question was resolved by my earlier response.