Page 1 of 2
How to simulate CMYK decoded as RGB?
Posted: 2017-07-19T04:05:44-07:00
by arbingordon
Bit of an odd request, I know, but how would I simulate CMYK incorrectly decoded as sRGB while staying in the sRGB colorspace?
I'll try and post a sample later today if that isn't clear enough
Thank you ^^
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-19T05:15:47-07:00
by snibgo
I don't understand. CMYK has 4 channels. sRGB has 3 channels. So what does "incorrectly decoded" mean?
In IM, you could read the CMYK file, separate, delete a channel, combine, then "-set colorspace sRGB". This might do what you want.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-19T16:00:02-07:00
by arbingordon
Yea, I had a feeling that might be unclear.
For example:
PNG Source
https://www.dropbox.com/s/xz7310y6a4met ... a.png?dl=0
PNG Source -> CMYK JPEG
https://www.dropbox.com/s/z53m2r9zprytqpt/cmyk.jpg?dl=0
PNG Source -> CMYK JPEG, incorrectly decoded with ms paint, resaved as PNG
https://www.dropbox.com/s/ml0shmsoiqpbs ... d.png?dl=0
I'm not sure how things are getting mangled, but I expect it's something along the lines of CMY being remapped into RGB (ie C->B, M->R, Y->G), not entirely sure though.
I'll keep playing around with -set colorspace to see if I can get anything similar.
Thanks
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-19T16:18:50-07:00
by snibgo
Your third link doesn't look mangled. It's a slightly tweaked version of the Lenna image, somewhat desaturated.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-19T18:03:31-07:00
by fmw42
I think the main difference between your two results is that the first one has an "sRGB IEC61966-2-1 black scaled" profile and the one you think is wrong has no profile. Look at the results from identify -verbose yourimage. Profiles can make a difference in the way it looks.
The data is slightly different (2.7%) as shown by compare
Code: Select all
compare -metric rmse cmyk.jpg cmyk_incorrectly_decoded.png null:
1761.91 (0.026885)
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-20T19:20:44-07:00
by arbingordon
I think I'm still not being clear here.
Regarding the "two results", I'm not sure that's very accurate. Like I said, cmyk.jpg was derived by just converting from the PNG source using imagemagick. I understand that the wrong one has no profile - presumably because ms paint and other non-compliant decoders don't handle the profile correctly. Interesting to note however, that among the 3 images I linked, none report having a profile per say (
https://pastebin.com/tTTQrc7c )- unless by profile you meant colorspace field under the verbose output, but even that is sRGB, and not the fully qualified "sRGB IEC61966-2-1 black scaled" colorspace. That has me interested however, maybe it would be possible to achieve what I'm going for by converting to CMYK and then forcibly setting the colorspace back to sRGB, although I didn't have any luck with that earlier.
As a sidenote, I made an 8bit colormap covering from #000000-#FFFFFF (easy enough to do in a few lines of python), then imported that as RGB, converted it to CMYK colorspace, and exported as lossless TIF. Then loaded that into paint and resaved as bitmap to have a (albeit large) mapping table to map from RGB to this sort of pseudo colorspace. With that mapping table, I can just iterate over each pixel in the source, and replace each pixel according to that table. Only problem doing this is, think it could be done faster if it was done purely in imagemagick. Is there a way to remap based on a color mapping file? (not an ICC profile, but off an existing image with specific characteristics.)
The initial colormap (#000000-#FFFFFF)
https://www.dropbox.com/s/b8rwiny5rn0nl ... p.png?dl=0
The "error" colormap (not sure what else to call it)
https://www.dropbox.com/s/pmeiges2ev5tv ... p.png?dl=0
Let me know your thoughts on the matter.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-20T20:26:51-07:00
by fmw42
According to ImageMagick identify -verbose, it has "sRGB IEC61966-2-1 black scaled" profile.
Code: Select all
Image: cmyk.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 512x512+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 262144
Red:
min: 60 (0.235294)
max: 255 (1)
mean: 184.865 (0.724961)
standard deviation: 40.2133 (0.157699)
kurtosis: -0.786883
skewness: -0.613539
entropy: 0.937151
Green:
min: 0 (0)
max: 246 (0.964706)
mean: 117.807 (0.46199)
standard deviation: 48.613 (0.190639)
kurtosis: -0.701391
skewness: -0.101691
entropy: 0.954101
Blue:
min: 11 (0.0431373)
max: 218 (0.854902)
mean: 104.063 (0.40809)
standard deviation: 35.061 (0.137494)
kurtosis: -0.288041
skewness: 0.484799
entropy: 0.919093
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 119.421 (0.468319)
standard deviation: 54.6132 (0.214169)
kurtosis: -0.923633
skewness: 0.100305
entropy: 0.936782
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 512x512+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 80
Orientation: Undefined
Properties:
date:create: 2017-07-20T20:27:21-07:00
date:modify: 2017-07-20T20:27:21-07:00
icc:copyright: Dropbox, Inc.
icc:description: sRGB IEC61966-2-1 black scaled <------ see profile here
icc:manufacturer: sRGB IEC61966-2-1 black scaled
icc:model: sRGB IEC61966-2-1 black scaled
jpeg:colorspace: 2
jpeg:sampling-factor: 2x2,1x1,1x1
signature: abb5d0d696e90ff59ec4db53fd5ecec59d4b02823878708aff7367a4b32452c7
Profiles:
Profile-icc: 564 bytes
Artifacts:
filename: cmyk.jpg
verbose: true
Tainted: False
Filesize: 41679B
Number pixels: 262144
Pixels per second: 26.2144MB
User time: 0.010u
Elapsed time: 0:01.009
Version: ImageMagick 6.9.9-0 Q16 x86_64 2017-07-16 http://www.imagemagick.org
For remapping according to a colortable image see -remap at
http://www.imagemagick.org/Usage/quantize/#remap and use +dither or -dither none.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-20T21:25:57-07:00
by arbingordon
As you can see from the pastebin earlier, identify wasn't reporting any of that information. I guess it has to do with me being a few months out of date on my installed copy of imagemagick (ImageMagick 6.9.8-0 Q16 x64 2017-03-11).
I'll try updating my 7.X install (trying to keep 6.X where it's at to avoid breaking python wand bindings), and see if that gives me the additional profile info.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-20T22:04:38-07:00
by fmw42
check your libpng and update it to the latest.
convert -list format
PNG* PNG rw- Portable Network Graphics (libpng 1.6.29,1.6.30)
Not sure why listing is showing two versions. MacPorts only has one listed as active.
libpng @1.6.29_0
libpng @1.6.30_0 (active)
This is weird. I have not seen that before.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-20T23:15:39-07:00
by arbingordon
I updated to ImageMagick 7.0.6-1 Q16 x64 2017-07-15, but it's interesting that I cannot reproduce your verbose options.
The verbose output is as follows:
Code: Select all
Image: cmyk.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 512x512+0+0
Units: Undefined
Type: ColorSeparation
Endianess: Undefined
Colorspace: CMYK
Depth: 8-bit
Channel depth:
Cyan: 8-bit
Magenta: 8-bit
Yellow: 8-bit
Black: 8-bit
Channel statistics:
Pixels: 262144
Cyan:
min: 0 (0)
max: 72 (0.282353)
mean: 1.79726 (0.00704806)
standard deviation: 3.72136 (0.0145936)
kurtosis: 47.416
skewness: 5.43316
entropy: 0.399016
Magenta:
min: 0 (0)
max: 253 (0.992157)
mean: 125.014 (0.490251)
standard deviation: 47.6473 (0.186852)
kurtosis: -0.652454
skewness: -0.148786
entropy: 0.944862
Yellow:
min: 0 (0)
max: 251 (0.984314)
mean: 102.496 (0.401944)
standard deviation: 37.1756 (0.145787)
kurtosis: -0.059145
skewness: -0.787878
entropy: 0.923729
Black:
min: 0 (0)
max: 200 (0.784314)
mean: 74.5686 (0.292426)
standard deviation: 48.9337 (0.191897)
kurtosis: -0.757828
skewness: 0.713265
entropy: 0.94823
Image statistics:
Overall:
min: 0 (0)
max: 253 (0.992157)
mean: 75.9689 (0.297917)
standard deviation: 60.5663 (0.237515)
kurtosis: -1.17537
skewness: 0.210133
entropy: 0.803959
Total ink density: 232.157%
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 512x512+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 92
Orientation: Undefined
Properties:
date:create: 2017-07-21T02:09:04-04:00
date:modify: 2017-07-21T02:09:04-04:00
jpeg:colorspace: 4
jpeg:sampling-factor: 1x1,1x1,1x1,1x1
signature: 2f2a7182c3f2f90d774e99f66475a1e3af04007d49c1cc05507865b700eb6592
Artifacts:
verbose: true
Tainted: False
Filesize: 195767B
Number pixels: 262144
Pixels per second: 37.4493MB
User time: 0.016u
Elapsed time: 0:01.006
Version: ImageMagick 7.0.6-1 Q16 x64 2017-07-15 http://www.imagemagick.org
As for the libpng version:
Code: Select all
PNG* PNG rw- Portable Network Graphics (libpng 1.6.29)
See http://www.libpng.org/ for details about the PNG format.
PNG00* PNG rw- PNG inheriting bit-depth, color-type from original, if possible
PNG24* PNG rw- opaque or binary transparent 24-bit RGB (zlib 1.2.9)
PNG32* PNG rw- opaque or transparent 32-bit RGBA
PNG48* PNG rw- opaque or binary transparent 48-bit RGB
PNG64* PNG rw- opaque or transparent 64-bit RGBA
PNG8* PNG rw- 8-bit indexed with optional binary transparency
I'm using the prebuilt windows builds by the way, not sure if you're assuming that I've built from source or anything.
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-20T23:23:07-07:00
by arbingordon
Can't believe I didn't read your post more clearly - yea it looks like dropbox is fudging things. Depending on how you save the image from their site, it will add the profile or give you the original untouched source. Here's a zip with the original files, hopefully dropbox can't malform them then
https://www.dropbox.com/s/vp7pzgyt6vb8vd3/cmyk.zip?dl=0
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-21T09:46:18-07:00
by fmw42
Your two files are quite different. The "correct" one is CMYK. The "bad" one is sRGB.
Code: Select all
Image: cmyk.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 512x512+0+0
Units: Undefined
Type: ColorSeparation
Endianess: Undefined
Colorspace: CMYK
Depth: 8-bit
Channel depth:
cyan: 8-bit
magenta: 8-bit
yellow: 8-bit
black: 8-bit
Channel statistics:
Pixels: 262144
Cyan:
min: 0 (0)
max: 72 (0.282353)
mean: 1.79731 (0.00704826)
standard deviation: 3.72137 (0.0145936)
kurtosis: 47.4156
skewness: 5.43311
entropy: 0.399022
Magenta:
min: 0 (0)
max: 253 (0.992157)
mean: 125.014 (0.49025)
standard deviation: 47.6472 (0.186852)
kurtosis: -0.652458
skewness: -0.148792
entropy: 0.944862
Yellow:
min: 0 (0)
max: 251 (0.984314)
mean: 102.496 (0.401944)
standard deviation: 37.1756 (0.145787)
kurtosis: -0.0591612
skewness: -0.787875
entropy: 0.92373
Black:
min: 0 (0)
max: 200 (0.784314)
mean: 74.5686 (0.292426)
standard deviation: 48.9337 (0.191897)
kurtosis: -0.757827
skewness: 0.713265
entropy: 0.948229
Image statistics:
Overall:
min: 2 (0.00784314)
max: 255 (1)
mean: 179.031 (0.702083)
standard deviation: 60.5663 (0.237515)
kurtosis: -1.17538
skewness: 0.210131
entropy: 0.803961
Total ink density: 232.157%
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: cmyk(255,255,255,0)
Border color: cmyk(223,223,223,0)
Matte color: cmyk(189,189,189,0)
Transparent color: cmyk(0,0,0,0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 512x512+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 92
Orientation: Undefined
Properties:
date:create: 2017-07-20T23:28:13-07:00
date:modify: 2017-07-19T07:51:40-07:00
jpeg:colorspace: 4
jpeg:sampling-factor: 1x1,1x1,1x1,1x1
signature: 709c112052f908e0223ef07da691c67349a277791cf29133b6250f1167491a6d
Artifacts:
filename: cmyk.jpg
verbose: true
Tainted: False
Filesize: 195767B
Number pixels: 262144
Pixels per second: 26.2144MB
User time: 0.010u
Elapsed time: 0:01.009
Version: ImageMagick 6.9.9-0 Q16 x86_64 2017-07-16 http://www.imagemagick.org
Code: Select all
Image: cmyk_incorrectly_decoded.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 512x512+0+0
Resolution: 37.8x37.8
Print size: 13.545x13.545
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Pixels: 262144
Red:
min: 75 (0.294118)
max: 255 (1)
mean: 181.326 (0.711081)
standard deviation: 40.4909 (0.158788)
kurtosis: -0.822027
skewness: -0.546814
entropy: 0.949539
Green:
min: 29 (0.113725)
max: 249 (0.976471)
mean: 119.69 (0.469373)
standard deviation: 43.0388 (0.16878)
kurtosis: -0.672884
skewness: 0.132667
entropy: 0.951982
Blue:
min: 34 (0.133333)
max: 221 (0.866667)
mean: 102.647 (0.402539)
standard deviation: 31.3499 (0.122941)
kurtosis: -0.0195183
skewness: 0.695498
entropy: 0.915276
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: -3
skewness: 0
entropy: nan
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 154.084 (0.604252)
standard deviation: 73.2801 (0.287373)
kurtosis: -1.09992
skewness: -0.000353022
entropy: nan
Rendering intent: Perceptual
Gamma: 0.45455
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 512x512+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2017-07-20T23:28:13-07:00
date:modify: 2017-07-19T07:54:36-07:00
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:gAMA: gamma=0.45454544 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 512, 512
png:pHYs: x_res=3780, y_res=3780, units=1
png:sRGB: intent=0 (Perceptual Intent)
png:text: 2 tEXt/zTXt/iTXt chunks were found
signature: 1753dbe34ebca0d24802b4e63474369496ef8699fdb46ddbbbe11a7344600575
Artifacts:
filename: cmyk_incorrectly_decoded.png
verbose: true
Tainted: False
Filesize: 496175B
Number pixels: 262144
Pixels per second: 26.2144MB
User time: 0.010u
Elapsed time: 0:01.009
Version: ImageMagick 6.9.9-0 Q16 x86_64 2017-07-16 http://www.imagemagick.org
I do not understand what you are trying to do and why? What was the ImageMagick command used to make the "bad" one? What did you do to create the "good" one?
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-22T01:14:02-07:00
by arbingordon
fmw42 wrote: ↑2017-07-21T09:46:18-07:00
I do not understand what you are trying to do and why?
Like it says in the title, I'm trying to simulate CMYK colorspace images being (incorrectly) decoded as RGB (well technically sRGB) by non-compliant software. (eg, ms paint, windows photo viewer, don't know of any non-compliant decoders that are cross platform
yet.
I understand that this is an unconventional request.
What was the ImageMagick command used to make the "bad" one?
convert Lenna.png -colorspace CMYK cmyk.jpg, then opened in ms paint, and saved as PNG.
(the latter part is what I am trying to simulate, outdated non-compliant software)
What did you do to create the "good" one?
convert Lenna.png -colorspace CMYK cmyk.jpg
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-22T08:20:36-07:00
by snibgo
If it was misinterpreting CMYK as sRGB, you might get something like this:
Code: Select all
convert lena.png -colorspace CMYK -separate -delete 3 -set colorspace sRGB -combine -quality 40 bad_lena.jpg
Re: How to simulate CMYK decoded as RGB?
Posted: 2017-07-22T10:31:26-07:00
by fmw42
PNG does not support CMYK. What your software does to "treat" it as sRGB is unknown. Perhaps it just drops the K channel and has CMY put into the RGB channels or perhaps negates them first.
But what I don't understand is why you want to recreate such bad behavior? Why not just convert properly?