ImageJ Unsharp mask in ImageMagick

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
bhim.rathor
Posts: 21
Joined: 2016-02-21T13:47:15-07:00
Authentication code: 1151

ImageJ Unsharp mask in ImageMagick

Post by bhim.rathor »

Can somebody please help achieving the ImageJ unsharp mask in ImageMagick. Its available in IMageJ->Process->Filters->UnsharpMask. I need to be able to provide exact same parameters as in this filter i.e. Radius(Sigma) and and Mask Weight(0.1-0.9)

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageJ Unsharp mask in ImageMagick

Post by fmw42 »

for ImageJ sigma=1, mask weight=0.6, try

Code: Select all

-unsharp 0x1+1.6
bhim.rathor
Posts: 21
Joined: 2016-02-21T13:47:15-07:00
Authentication code: 1151

Re: ImageJ Unsharp mask in ImageMagick

Post by bhim.rathor »

Thanks for help.

I ran this, however the result is completely different than what ImageJ gives. I tried sigma =100 and mask weight =0.9. I have uploaded in and out images at https://drive.google.com/open?id=0B9dG4 ... 25vX0pSeHM . This is the command i used

convert -unsharp 0x100+1.9 C:\Unsharp\US_IM.tiff C:\Unsharp\US_IM_After.tiff

How do i make it give the same result.

Thanks
Bhim
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageJ Unsharp mask in ImageMagick

Post by fmw42 »

100 is way too large for a sigma value in IM when ImageJ uses a value of 1.
convert -unsharp 0x100+1.9 C:\Unsharp\US_IM.tiff C:\Unsharp\US_IM_After.tiff
In IM, proper syntax is to read the input before doing any operations on it. See http://www.imagemagick.org/Usage/basics/#syntax and http://legacy.imagemagick.org/script/co ... essing.php.

So try

Code: Select all

convert C:\Unsharp\US_IM.tiff -unsharp 0x1+1.9+0 C:\Unsharp\US_IM_After.tiff

Input:
Image

I get pretty close results for:

ImageJ: sigma=1 and weight 0.6

Image


And IM:

Code: Select all

convert lena.jpg -unsharp 0x1+1.6+0 -depth 8 lena_IM_us_1x1p6x0.tif
Image

Code: Select all

compare -metric rmse lena_IJ_us_1x0p6.tif lena_IM_us_1x1p6x0.tif null:
953.629 (0.0145514)
So only 1.45% different

Without knowing exactly what radius and threshold ImageJ is using, one would have to test quite a bit more to get closer. You can try adjusting the values in IM. See http://legacy.imagemagick.org/script/co ... hp#unsharp
Post Reply