Implement This Filter

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?".
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Implement This Filter

Post by johnthomas1433 »

While browsing through the web, I came across this image, and I'm wondering whether it can be implemented through ImageMagick. The first image is the original image, and the second image is the filtered image.

Image
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Implement This Filter

Post by glennrp »

You can tinker with -sepia-tone and -gamma.

Code: Select all

convert photoshop*.jpg -sepia-tone 80% -gamma 1.2,.5,.8 ...

comes fairly close to your objective, but looks a little warmer. You also
seem to have a slight "fog" effect which I did not try to reproduce.
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

Thanks for your reply!

How to implement that fog effect ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Implement This Filter

Post by fmw42 »

You may be able to achieve the fog effect by adding some white to the image and then adding a vignette effect.

see -colorize and -vignette


Also please identify your version of IM and platform.
Last edited by fmw42 on 2013-11-02T11:37:53-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post by snibgo »

If the OP provides the link to the original page, we might get a hint.

This is fairly close, but noticably wrong in the top-right highlights. Windows script:

Code: Select all

%IM%convert effect.jpg ^
  -channel R -level -73.91%%,81.91%% ^
  -channel G -level -4%%,96%% ^
  -channel B -level -78.58%%,213.08%% ^
  +channel ^
  e.jpg
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: Implement This Filter

Post by fmw42 »

It is like the Toaster Effect from Instagram. The following Photoshop tutorial explains how to create it.

http://www.photoshoproadmap.com/video/yt/PmWE-FZOgyU/

It was effect 31 at http://designrfix.com/resources/33-amaz ... -tutorials
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post by snibgo »

The main fault with my attempt above is the lack of a vignette effect. I'll create a mask for a vignette. This is white in the centre, black in the corners, with equal values in the centre of each edge (thus has elliptical contours).

Code: Select all

FOR /F "usebackq" %%L IN (`%IM%identify -format "WIDTH=%%w\nHEIGHT=%%h" e.jpg`) DO set %%L

FOR /F %%i ^
IN ('%IM%identify ^
  -ping ^
  -format "%%[fx:max(%WIDTH%,%HEIGHT%)]" ^
  xc:') ^
DO set MAX=%%i

FOR /F %%i ^
IN ('%IM%identify ^
  -ping ^
  -format "%%[fx:int(%MAX%*sqrt(2)+0.5)]" ^
  xc:') ^
DO set DIM=%%i

"%IM%convert" ^
  -size %DIM%x%DIM% ^
  radial-gradient: ^
  -gravity Center -crop %MAX%x%MAX%+0+0 +repage ^
  -resize "%WIDTH%x%HEIGHT%^!" ^
  vig_mask.png
Then I use this mask twice, to reduce saturation and then lightness in the corners. The two levels give different fades.

Code: Select all

"%IM%convert" ^
  e.jpg ^
  ( -clone 0 -modulate 100,0,100 ) ^
  ( vig_mask.png -negate -level 50%%,95%% ) ^
  -composite ^
  ( -clone 0 -modulate 90,100,100 ) ^
  ( vig_mask.png -negate -level 60%%,100%% ) ^
  -composite ^
  e2.png
I shouldn't use JPEG as an intermediate format, but it probably adds to the overall horrible degraded appearance.
snibgo's IM pages: im.snibgo.com
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

fmw42 wrote:Also please identify your version of IM and platform.
My IM version is 6.8.7-0 and I'm running it on Windows (will the same code produce a different effect in Linux or other OS ?)
snibgo wrote:If the OP provides the link to the original page, we might get a hint.
I see that fmw42 has already posted the link. Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Implement This Filter

Post by fmw42 »

johnthomas1433 wrote: My IM version is 6.8.7-0 and I'm running it on Windows (will the same code produce a different effect in Linux or other OS ?)
No, but almost. There are some syntax differences between IM on Windows and IM on Unix (Linux, Mac)

See http://www.imagemagick.org/Usage/windows/

The code provided above by snibgo is for Windows.
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

johnthomas1433 wrote:
fmw42 wrote:Also please identify your version of IM and platform.
My IM version is 6.8.7-0 and I'm running it on Windows (will the same code produce a different effect in Linux or other OS ?)
snibgo wrote:If the OP provides the link to the original page, we might get a hint.
I see that fmw42 has already posted the link. Thanks
snibgo wrote:This is fairly close, but noticably wrong in the top-right highlights. Windows script:

Code: Select all

%IM%convert effect.jpg ^
  -channel R -level -73.91%%,81.91%% ^
  -channel G -level -4%%,96%% ^
  -channel B -level -78.58%%,213.08%% ^
  +channel ^
  e.jpg
That is pretty close! But like you have said, it does lack a vignette effect.
fmw42 wrote:No, but almost. There are some syntax differences between IM on Windows and IM on Unix (Linux, Mac)
See http://www.imagemagick.org/Usage/windows/
The code provided above by snibgo is for Windows.
Thanks for the link! I'm using it now on Windows, but I may have to use it later on a Linux system.
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

snibgo wrote:I'll create a mask for a vignette. This is white in the centre, black in the corners, with equal values in the centre of each edge (thus has elliptical contours).

Code: Select all

FOR /F "usebackq" %%L IN (`%IM%identify -format "WIDTH=%%w\nHEIGHT=%%h" e.jpg`) DO set %%L

FOR /F %%i ^
IN ('%IM%identify ^
  -ping ^
  -format "%%[fx:max(%WIDTH%,%HEIGHT%)]" ^
  xc:') ^
DO set MAX=%%i

FOR /F %%i ^
IN ('%IM%identify ^
  -ping ^
  -format "%%[fx:int(%MAX%*sqrt(2)+0.5)]" ^
  xc:') ^
DO set DIM=%%i

"%IM%convert" ^
  -size %DIM%x%DIM% ^
  radial-gradient: ^
  -gravity Center -crop %MAX%x%MAX%+0+0 +repage ^
  -resize "%WIDTH%x%HEIGHT%^!" ^
  vig_mask.png
Then I use this mask twice, to reduce saturation and then lightness in the corners. The two levels give different fades.
You have lost me here, as I'm a newbie to Imagemagick. Can you kindly explain how you implemented the vignette effect? Wont -vignette command work here ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post by snibgo »

The same IM commands should produce identical results on any platform. My commands above use Windows "FOR". Unix works differently.

If you run my commands and look at vig_mask.png, you should see it is as I described. My final convert does two operations:

1. Makes a copy of e.jpg with zero-saturation (ie monochrome), and compose it over e.jpg, but only at the edges.

2. Makes another copy of e.jpg, but slightly darker, and compose this over the previous result, but only at the edges.

You could do it with "-vignette" instead. My version gives greater control over the width and placement of the transition between the original and the two copies.
snibgo's IM pages: im.snibgo.com
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

When I try the first line of your code in the command prompt

Code: Select all

FOR /F "usebackq" %%L IN (`%IM%identify -format "WIDTH=%%w\nHEIGHT=%%h" e.jpg`) DO set %%L
I'm getting the error as

Code: Select all

%%L was unexpected at this time
What am I doing wrong ?
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

johnthomas1433 wrote:When I try the first line of your code in the command prompt

Code: Select all

FOR /F "usebackq" %%L IN (`%IM%identify -format "WIDTH=%%w\nHEIGHT=%%h" e.jpg`) DO set %%L
I'm getting the error as

Code: Select all

%%L was unexpected at this time
What am I doing wrong ?
My bad. Didnt see it as a bash script
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post by johnthomas1433 »

...
Post Reply