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 » 2016-09-03T10:11:36-07:00

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: 22095
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 » 2016-09-03T10:16:46-07:00

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 » 2016-09-03T10:20:39-07:00

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: 9397
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo » 2016-09-03T10:37:03-07:00

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 » 2016-09-04T12:14:50-07:00

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: 22095
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 » 2016-09-04T12:44:16-07:00

Is this a PAID consulting activity? If not, then it needs to be moved to the Users forum.

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

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo » 2016-09-04T13:01:07-07:00

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 » 2016-09-04T13:08:52-07:00

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 » 2016-09-04T13:09:42-07:00

Also, do you have a paypal donation button? I really feel I need to give something back to you!

User avatar
fmw42
Posts: 22095
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 » 2016-09-04T13:19:55-07:00

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: 9397
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo » 2016-09-04T14:14:05-07:00

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 » 2016-09-04T18:12:31-07:00

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: 9397
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Recreate ImageMagick script to Photoshop Action

Post by snibgo » 2016-09-04T18:59:40-07:00

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: 22095
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Recreate ImageMagick script to Photoshop Action

Post by fmw42 » 2016-09-04T19:04:31-07:00

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 » 2016-09-05T08:30:58-07:00

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