Page 1 of 1

CMYK image getting black on applying unsharp mask

Posted: 2016-11-09T16:57:09-07:00
by gegupta
HI,

IM version: ImageMagick 6.9.6-3 Q16 x86_64 2016-11-09
Webp version: libwebp-0.5.1

I am trying to resize and apply unsharp mask to a CMYK image. If i do this with target format JPG, i see after applying unsharp mask the image blackens. But same is not true if i convert to webp. I wanted to know if there is anything special with this image. Also same is not true for all cmyk images.

CMYK image : https://drive.google.com/open?id=0B_Gde ... VpUMF9VRnM

For JPEG:
Before resize : https://drive.google.com/open?id=0B_Gde ... HdZZFV1bW8
After resize: https://drive.google.com/open?id=0B_Gde ... S0yYjh4LUk
After unsharp mask : https://drive.google.com/open?id=0B_Gde ... 0ZnTHhNblk

For Webp :
Before resize : https://drive.google.com/open?id=0B_Gde ... ndyUzJqbTQ
After resize: https://drive.google.com/open?id=0B_Gde ... WxicUVGUUk
After unsharp mask : https://drive.google.com/open?id=0B_Gde ... lp0dHc1d1k

Steps i am following :

Code: Select all

Image image_;
image_.read(fileName_);
image_.quality(80);
image_.filterType(TriangleFilter);
image_.magick("JPG"/"WEBP");
image_.write("BeforeResize.jpg");
image_.resize( boost::lexical_cast<string>(400+"x"+ 400 + "!");
image_.write("AfterResize.jpg");
image_.unsharpmask(0.8,0.5,1.2,0.05);
image_.write("AfterSHarpen.jpg");

Re: CMYK image getting black on applying unsharp mask

Posted: 2016-11-09T18:12:32-07:00
by fmw42
Unsharp probably expects the image to be RGB. I would strongly suggest that you convert to sRGB colorspace (preferably by profiles). Many viewers do not display CMYK properly without a profile. So if you insist on having CMYK output, then convert the input via profile to sRGB, process your image, then convert back to CMYK with a profile.

As a simple test, this seems to work without profiles for me on IM 6.9.6.4 Q16 Mac OSX

Code: Select all

convert cmyk.JPG -colorspace sRGB -resize 400x400! -unsharp 0.8,0.5+1.2+0.05 -colorspace CMYK result.jpg

Re: CMYK image getting black on applying unsharp mask

Posted: 2016-11-10T14:25:59-07:00
by gegupta
Is there an API alternate to do it as in in c++?

Re: CMYK image getting black on applying unsharp mask

Posted: 2016-11-10T14:28:26-07:00
by fmw42
I am sure there is, but I do not use any API, so I cannot help.