Recreate ImageMagick script to Photoshop Action

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

Hello folks!

I need a Photoshop Action that converts an Absolute map into a Relative one.

Snigbo kindly provided me a way to convert Absolute into Relative using ImageMagick, which he explained bellow.
But I need a Photoshop workflow, as I am not familiar with ImageMagick.


"The identity relative map is constant 50% gray, so distorting it doesn't change it; it remains a constant 50% gray. If we want to distort an identity map to get a distortion map, we have to distort the identity absolute map. The distorted result is an absolute distortion map, which we can convert to a relative distortion map using"

relative = absolute - ident_absolute + 50%

set IDENT=^
0,0,#008,^
%%[fx:w-1],0,#f08,^
0,%%[fx:h-1],#0f8,^
%%[fx:w-1],%%[fx:h-1],#ff8

%IM32i%convert ^
abs_map.png ^
( +clone ^
-sparse-color bilinear "%IDENT%" ^
) ^
-compose Mathematics ^
-define compose:args=0,-1,1,0.5 ^
-composite ^
+depth ^
rel_map.tiff




Source:
Snigbdo comment on the following thread:
https://www.imagemagick.org/discourse-s ... ap#p136758
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 »

Perhaps you should post to a Photoshop forum, since this is not really an Imagemagick issue any longer, if you want all work done in Photoshop. Most people here do not use Photoshop. They use Imagemagick to do their work. So you would be very lucky to find someone who can help you on this forum.
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

I also posted on a Photoshop Forum. But the same applies there, most PS users don't know ImageMagick.

I think ti's easier to find a ImageMagick user that know PS, than the inverse. This is why I am asking here. Hope it makes sense! ; )
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo »

I don't use Photoshop, but I expect the task is totally trivial: take the input image, subtract another, and add 50%. The second image must be the same size as the first, with the specified colours in the corners, linearly interpolated between the corners.
snibgo's IM pages: im.snibgo.com
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

Thanks again Snigbo, you are the man! ; )

What you mean by "add 50"?

Based on what you mentioned, here is what I did in PS:

1- Distorted the absolute image (perspective distort) to create the "absolute distorted map"
https://gyazo.com/3f2355988939e9425e87b921ca8a9fba

2- Applied "difference" in PS:

- Absolute distorted map with "difference effect" (top layer)
https://www.dropbox.com/s/xmq35rgwhayeq ... p.png?dl=0

- Absolute image with same dimensions (bottom layer)
https://www.dropbox.com/s/d3gb4dyp899ij ... e.png?dl=0


3- It came out like this
https://gyazo.com/69b7a1168df2b65b5d20a79a8019dfd0

File:
https://www.dropbox.com/s/p219j8r5w6q06 ... 9.png?dl=0

Is the resulted relative map correct?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 »

Is this a PAID consulting activity? If not, then it needs to be moved to the Users forum.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo »

snibgo wrote:relative = absolute - ident_absolute + 50%
Adding 50% means: to each channel, add 50% of the range of possible values. So 0% (black) will become 50% (middle gray), and 50% gray will become 100% (white), and so on.

The result of the subtraction can be negative, for example -10%, so adding 50% makes it +40%.

If you take an identity absolute map, and don't distort it at all, and put that through your process, the resulting relative map should be entirely 50% gray.

If you do distort it slightly, the resulting relative map should be roughly 50% gray.
snibgo's IM pages: im.snibgo.com
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

Thanks Snigbo, will find someone to help me to do this in PS!

if is something easy for you, could you provide a PNG with the relative map, for the absolute one bellow?
https://www.dropbox.com/s/xmq35rgwhayeq ... p.png?dl=0

It would be my benchmark to help me realize when I get it done! ; )
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

Also, do you have a paypal donation button? I really feel I need to give something back to you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 »

snibgo wrote:If you take an identity absolute map, and don't distort it at all, and put that through your process, the resulting relative map should be entirely 50% gray.

If you do distort it slightly, the resulting relative map should be roughly 50% gray.
I will add one more slight comment. In IM, in a relative distortion map 50% gray means "no change" between input position and output position. Larger values shift the pixel coordinates one way and smaller values the other way.

I do not know how that works in Photoshop or even if 50% is the no change value.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo »

alexlsg wrote:if is something easy for you, could you provide a PNG with the relative map, for the absolute one bellow?
https://www.dropbox.com/s/xmq35rgwhayeq ... p.png?dl=0
Your link is broken. If you mean absolute-distorted-map.png you linked above, the corresponding relative map is:
Image
However, the anti-aliased edges may need separate processing.

On the content of relative maps: see my post at https://www.imagemagick.org/discourse-s ... 15#p136701, and the link from there to the SVG spec.
snibgo's IM pages: im.snibgo.com
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

Very cool Snigbo, it's working!

You can see it live, just choose one of the images from the "imagens" section
http://tshirtproject.wpengine.com/design/

However there are still lots of transparent pixels, and incorrect perspective/wrap.
https://gyazo.com/99d2a23978c0a422a7a9d798a221f121

Maybe it's because the absolute distorted map I sent is in low quality? Is I send a Tif or EXR 32 bits/ channel would help to convert to a "pixel perfect" Relative map?

again, thanks so much! : )
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo »

I can't get to either of those links.

Your file absolute-distorted-map.png is 500x500, and only 8 bits per channel per pixel. The expected error with 8-bit images is about 1 part in 256. Over 500 pixels, this is an error in position of about 2 pixels, which will be obvious.

In experiments with 7500x5000 pixels files, 32 bits/channel/pixel is needed for best results. For web-size images, perhaps 16 bits is enough. But 8 certainly isn't.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 »

I have moved this here, since it does not appear to be primarily about Imagemagick nor Paid Consulting.
alexlsg
Posts: 45
Joined: 2016-08-03T08:04:20-07:00
Authentication code: 1151

Re: Recreate ImageMagick script to Photoshop Action

Post by alexlsg »

fmw42 wrote:I have moved this here, since it does not appear to be primarily about Imagemagick nor Paid Consulting.
Ok Fred, thanks!
Post Reply