Distort sharpening from photo reduction

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
tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Distort sharpening from photo reduction

Post by tackd »

Hi.

I'm resizing photos over 3000 wide, to 1024 wide. I've racked my brains for a great imagemagick formula.

Code: Select all

convert DSCF2915-21.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -sampling-factor 1x1 -quiet -density 72 -units PixelsPerInch -colorspace sRGB DSCF2915-21.jpg
Question: I like the sharpening when using <distort>, but the resulting image is distorted a little.
Can I achieve the above formula in a different way, maintaining the sharpness 'without' any distortion ?

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

Re: Distort sharpening from photo reduction

Post by fmw42 »

try adding -set colorspace RGB before converting back to sRGB

Code: Select all

convert DSCF2915-21.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -sampling-factor 1x1 -quiet -density 72 -units PixelsPerInch -set colorspace RGB -colorspace sRGB DSCF2915-21.jpg
tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Re: Distort sharpening from photo reduction

Post by tackd »

Thanks fmw42.

Is your fix to prevent the distortion on the result ?

Am I using the 'distort' option correctly and is the distort option beneficial ?

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

Re: Distort sharpening from photo reduction

Post by fmw42 »

The addition of -set colorspace RGB is only to properly convert your result back to sRGB. If you convert to a colorspace other than sRGB, IM loses that information and you need to tell IM from what colorspace it is being converted when you go back to sRGB (or any other colorspace).

How you resize (-resize or -distort resize) depends whether you want a rectangular filter or a circular filter.

Sorry I do not understand what your problem is. Can you elaborate and/or provide example images?

You might try a different filter.

see
http://www.imagemagick.org/Usage/filter/
http://www.imagemagick.org/Usage/filter/nicolas/
tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Re: Distort sharpening from photo reduction

Post by tackd »

fmw42.

Thanks, I'll elaborate.

My objective is to reduce over 3000 pixel wide, 240 dpi landscape photography (.tif) to 1024, 72 dpi Jpeg.
I've tried various filters and am satisfied with the Lagrange. Someone recommended to use the
'distort' filter to increase the quality... I noticed an increased 'sharpening' effect using the 'distort',
but the result was stretched slightly from the original.

So I'm questioning if there is any benefit in using the 'distort' feature (at all) for my purposes,
or if it can be used without the slight stretching that occurs on the result.

Formula #1 uses; -distort Resize
Formula #2 uses; -resize

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

Re: Distort sharpening from photo reduction

Post by fmw42 »

I am not sure why you get a slight stretching. Anthony would have to comment on that. But it could be because of different algorithms being used. There is a 0.5 pixel issue that is commented here http://www.imagemagick.org/Usage/distor ... oordinates. I believe that distort resize uses image coordinates and resize uses pixel coordinates.

Can you post links to an example of this issue?
tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Re: Distort sharpening from photo reduction

Post by tackd »

Since the stretching is an unknown and you have not replied on if distort adds any additional benefit
e.g. -distort Resize vs. -resize... I'll have to leave it off to get my work done this evening.

Thank you much for your time.

Best regards.

http://www.imagemagick.org/Usage/resize/#distort_resize

Thank you.

[CLOSED]
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Distort sharpening from photo reduction

Post by anthony »

Note that both -distort Resize and -resize do not scale the X and Y equally, but almost equally. The differance is basically to keep the image 'interger' or 'pixel' aligned.

could this be the 'stretching' you are seeing. Note both do this in the same way (scaling). only distort does it as a single 2D filter pass, while resize does it as 2 seperate orthogonal passes with a internal intermedite image.


If this is not the 'stretching' you are talking about, then perhaps you need to explain it a little more.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply