Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
-
knr
- Posts: 8
- Joined: 2019-01-21T02:57:04-07:00
- Authentication code: 1152
Post
by knr » 2019-01-21T04:59:07-07:00
I have some RGB images with no gamma applied.
When I try to read the images like this
Code: Select all
PixelStorageSettings pixelStorageSettings = new PixelStorageSettings(100, 100, StorageType.Short, PixelMapping.BGR);
var colorImage = new MagickImage(myImageData, pixelStorageSettings);
The resulting colorImage says gamma is 0.4545.
How do I setup the pixel read so the image know it is gamma=1 data.
-
snibgo
- Posts: 11217
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Post
by snibgo » 2019-01-21T06:27:59-07:00
The "Image" structure has an element "gamma", which you can set.
-
knr
- Posts: 8
- Joined: 2019-01-21T02:57:04-07:00
- Authentication code: 1152
Post
by knr » 2019-01-21T07:21:24-07:00
colorImage has a Gamma property, but it is read only
and PixelStorageSettings has no Gamma setting
FYI: myImageData is a byte array
-
snibgo
- Posts: 11217
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Post
by snibgo » 2019-01-21T07:39:14-07:00
I don't think you can set the gamma before reading the image.
At the command line, "-set gamma 1.0" changes the gamma setting after the image has been read. Sorry, I don't know how to do that in Magick.NET.
-
knr
- Posts: 8
- Joined: 2019-01-21T02:57:04-07:00
- Authentication code: 1152
Post
by knr » 2019-01-25T01:46:45-07:00
There exists an option to set ColorSpace in ReadSettings as shown below:
Code: Select all
PixelStorageSettings pixelStorageSettings = new PixelStorageSettings(100, 100, StorageType.Short, PixelMapping.RGB);
pixelStorageSettings.ReadSettings.ColorSpace = ColorSpace.RGB;
pixelStorageSettings.ReadSettings.ColorType = ColorType.TrueColor;
var colorImage = new MagickImage(myImageData, pixelStorageSettings);
But the resulting image still has has
and not RGB.
I assume sRGB is RGB with standard gamma and RGB is RGB with no gamma.
Is this a bug or is the ReadSettings not intended to be used for this?
-
dlemstra
- Posts: 1533
- Joined: 2013-05-04T15:28:54-07:00
- Authentication code: 6789
-
Contact:
Post
by dlemstra » 2019-01-25T15:37:49-07:00
Not all read settings can/will be used when reading pixels, the Colorspace is one of them. If you want to do the same thing as "-gamma" you will need to call the GammaCorrect method of the MagickImage after you read it.
-
knr
- Posts: 8
- Joined: 2019-01-21T02:57:04-07:00
- Authentication code: 1152
Post
by knr » 2019-01-29T06:21:03-07:00
Ok.
If it is not posible to specifying gamma of the pixel data I read - how do I change colorspace with out ImageMagick first removes the gamma?
From:
https://imagemagick.org/script/command-line-options.php
Note, ImageMagick assumes the sRGB colorspace if the image format does not indicate otherwise. For colorspace conversion, the gamma function is first removed to produce linear RGB.
If a change colorspace on my pixeldata that do not have gamme applied I assume I get a wrong colorspace conversion.