image processing - photoshop parameters not good on graphicsmagick -


i'm trying translate photoshop setting sharpening images graphicsmagick. therefore found helpful article: https://redskiesatnight.com/2005/04/06/sharpening-using-image-magick/

the problem if use photoshop equivalent values explained in article in graphicsmagick images not sharp , clear on photoshop.

for example use settings on photoshop: strength: 500% radius: 2.0 pixel threshold: 8

in article parameters explained this:

the radius parameter

the radius parameter specifies (official documentation)

“the radius of gaussian, in pixels, not counting center pixel”

unsharp masking, many other image-processing filters, convolution kernel operation. filter processes image pixel pixel. each pixel examines block of pixels surrounding (the kernel) , calculations on them render output pixel value. radius parameter determines pixels surrounding center pixel considered in convolution kernel: (think of circle) larger radius, more pixels need processed each individual pixel.

image magick’s radius similar same parameter in photoshop, gimp , other image editors. in practical terms, affects size of “halos” created increase contrast along edges in image, increasing acutance , apparent sharpness.

how know how big of radius use? depends on output target resolution, 1 thing. depends on personal preferences, specific needs of image @ hand. far resolution issue goes, gimp user manual recommends unsharp mask radius set follows:

radius = (output ppi / 30) * 0.2 similar commonly found rule of thumb:  radius = output ppi / 150 monitor 72 ppi resolution, you’d use radius of approximately 0.5; if targeting printer 

at 300 ppi you’d use value of 2.0. use these starting point; different images have different sharpening requirements, , individual preference consideration. [aside: there few postings around net (including referenced in article) suggest image magick accepts, not honor, fractional radii; is, if specify radius of 0.5 or 1.2 rounded, or defaults integer, or silently ignored, etc. not true, @ least of version 5.4.7, 1 using write article. can see doing following:

$ convert -unsharp 1.2x1.2+5+0 test.tif testo1.tif $ convert -unsharp 1.4x1.4+5+0 test.tif testo2.tif $ composite -compose difference test01.tif testo2.tif diff.tif $ display diff.tif can load them gimp or photoshop different layers , change blend mode “difference”; resulting image not black (you may need closely 0.2 difference in radius). no, mistaken impression comes fact there relationship between radius , sigma parameters, , if not specify sigma in relation radius, radius may indeed changed, or @ least not work expected. read on more on this.]

please note default radius (if not specify anything) 0, special value tells unsharp mask algorithm “select appropriate value radius”!.

the sigma parameter

the sigma parameter specifies (official documentation)

“the standard deviation of gaussian, in pixels”

this confusing parameter of four, because “invisible” in other implementations of unsharp masking, , sparsely documented. best explanation have found came google search unearthed archived mailing list thread had following snippet:

comparing results of

convert -unsharp 1.2x1+4+0 test test1.2x1+4+0

and

convert -unsharp 30x1+4+0 test test30x1+4+0

results in no significant differences latter takes approx. 50 times longer complete.

that not surprising. radius of 30 involves on order of 61x61 input pixels in convolution of each output pixel. radius of 1.2 involves 3x3 or 5x5 pixels.

please can give me hints, 'sigma' means?

it describes relative weight of pixels function of distance center of convolution kernel. small sigma, outer pixels have little weight. important clue comes documentation -unsharp option convert (emphasis mine):

the -unsharp option sharpens image. convolve image gaussian operator of given radius , standard deviation (sigma). reasonable results, radius should larger sigma. use radius of 0 have method select suitable radius.

combining 2 clues provides insight: sigma parameter gives control on how strength (given amount parameter) of sharpening “graduated” or lessened radiate away given pixel @ center of convolution matrix limit defined radius. testing confirms inferred conclusion, namely bigger sigma causes more pronounced sharpening given radius. why poster in mailing list question (above) did not see significant difference in sharpening though using amount of 400% (!!) , threshold of 0%; sigma of 1.0, strength of filter falls off rapidly noticed despite large difference in radius between 2 invocations. why man page says “for reasonable results, radius should larger sigma”; if not, sigma parameter not have graduated effect, designed, “soften” halos toward edges; instead applies amount evenly edge of radius (which may want in circumstances). general rule of thumb choosing sigma might be:

if radius < 1, sigma = radius else sigma = sqrt(radius) summary: choose radius first, choose sigma smaller or equal that. experimentation yield best results. please note default sigma (if not specify anything) 1.0. main culprit why people don’t see effect image magick’s unsharp mask operator other implementations of unsharp mask if using larger radius: unless bump parameter not getting full benefit of larger radius!

[aside: might wondering happens if sigma specifed larger radius. answer, documentation states, result may not “reasonable”. in testing, usual result sharpening extended @ specified amount edge of specified radius, , larger values of sigma have little if effect. in cases (e.g. radius < 0) specifying larger sigma increased effective radius (e.g. 1); may result of “sanity check” on parameters in code. in case, keep in mind algorithm designed sigma less or equal radius, , results may unexpected if used otherwise.]

the amount parameter

the amount parameter specifies (official documentation)

“the percentage of difference between original , blur image added original”

the amount parameter can thought of “strength” of sharpening: higher values increase contrast in halos more lower ones. large values may cause highlights on halos blow out or shadows on them block up. if happens, consider using lower amount higher radius instead.

amount should specified decimal value indicating percentage. so, example, if in photoshop use amount of 170 (170%), in image magick use 1.7.

please note default amount (if not specify anything) 1.0 (i.e. 100%).

the threshold parameter

the threshold parameter specifies (official documentation)

“as fraction of maxrgb, needed apply difference amount”

the threshold specifies minimum amount of difference between center pixel vs. sourrounding pixels in convolution kernel necessary apply local contrast enhancement. increasing value causes algorithm become less sensitive differences may define edges. specifying positive threshold used avoid sharpening smooth areas may contain noise (e.g. area of blue sky). if have noisy image, consider raising threshold, or using kind of smart sharpening technique instead.

the threshold parameter should specified decimal value indicating percentage. different gimp or photoshop, both specify threshold in actual pixel levels between 0 , maximum (for 8-bit images, 255).

please note default threshold (if not specify anything) 0.05 (i.e. 5%; corresponds threshold of .05 * 255 = 12-13 in photoshop). photoshop uses default threshold of 0 (i.e. no threshold) , unsharp masking applied evenly throughout image. if want need specify 0.0 value image magick’s threshold. undoubtedly source of confusion regarding image magick’s sharpening algorithm.

so did , come command:

gm convert file1.jpg -unsharp 2x1.41+5+0.03 file1_2x1.41+5+0.03.jpg 

but said images not sharpen in photoshop. experimented lot of other values without images. possible photoshop sharpening stuff graphicsmagick? or not library? main problem of using photoshop sharpenings want improve images on our linux server , photoshop not running on linux.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -