Extract the hard light from an image.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
coolperez8
Posts: 27
Joined: 2016-03-11T07:27:11-07:00
Authentication code: 1151

Extract the hard light from an image.

Post by coolperez8 »

So, let's say I have 2 images, what I want to do is try to get the hard light from an image using an image with the effect applied and an image without the effect, so if I were to apply the effect itself to the image without the effect I'd get the image with the effect. Here's what I'm talking about:

Let's say I have these two images:
Image 1:
Image
Image 2:
Image

What command can I run using these two images to get Image 3, so if I were to run the following command I'd end up again with Image 2.
Command: Convert 5jJtxyI.png jTIWxXS.png -compose hard-light -composite Restore.png

Image 3:
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extract the hard light from an image.

Post by snibgo »

To rephrase the question:

If we have images dst.png and out.png, and we know that out.png came from

Code: Select all

convert dst.png src.png -compose HardLight -composite out.png
... we want to find src.png. Is that correct?

If you knew src.png and wanted to find dst.png, this would be quite simple. One of two formulae are used, depending on the value of src, and both the formulae are reversible.

The two formulae are:

Code: Select all

out = 2*src*dst
out = 1 - 2*(1-src)*(1-dst)
But you don't know src, so don't know for each pixel which formula is used.

I think you could assume one of the formulae, and try the reverse of that. This gves you a version of src.png. Use this with HardLight, and compare the result with your initial out.png. Some of the pixels will be wrong, so those had the wrong formula, so recalculate those pixels with the inverse of the other formula.

But there may be a simpler method.
snibgo's IM pages: im.snibgo.com
coolperez8
Posts: 27
Joined: 2016-03-11T07:27:11-07:00
Authentication code: 1151

Re: Extract the hard light from an image.

Post by coolperez8 »

Yes, that is correct, but I don't know the command the achieve the desired result.
Post Reply