-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RGB colour space in Vips #580
Comments
Hi @alonit, This is actually deliberate -- it's very useful to have the interpretation of pixels separate from their numeric type.
For example, suppose you sum three 8-bit sRGB images. Now you need to store the values in a ushort image or you'll get clipping, but really the pixels still mean sRGB as defined above. If you now divide by three, you'll get proper sRGB back again, and you'll keep the full range of values. Systems like ImageMagick which link the numeric type and the pixel interpretation find this very difficult. They need to implement a special image average operation, because if you just sum and divide, many pixel values will be truncated. Fortunately, the new ImageMagick 7 has changed tack here. They now use double as the only numeric type and keep interpretation as a separate field, so they have moved much closer to libvips (though sill not as good, in my opinion, of course). libvips has five sRGB interpretations, in fact. They are:
For your scanner, I think you will need to treat the 16-bit images differently anyway to account for the gamma difference. |
Thanks for this explanation |
OK, I'll close. |
Hi,
I'm using Vips 8.4 C API on Windows 64bit OS.
My application scans tissues with a color camera and save all 3 channels (R,G,B) under single .tif file using OpenCV
imwrite
method, so that the output files can be 8bit per channel or 16bit per channel image files (depends on application configuration).Under this application Vips is reading those files using
vips_image_new_from_file
and process them to output some pyramids.The VipsImage objects:
Type
= VIPS_INTERPRETATION_sRGBBandFormat
= UCHARType
= VIPS_INTERPRETATION_RGB16BandFormat
= USHORTUsing ImageMagic
identify
command line tool to get the properties of those images, I get:Color space is sRGB as reported also by Vips.
Image magic identify thew color space as sRGB and not as reported by Vips (Vips report on RGB16 color space).
Is there an inconsistency in Vips color space typing? I think that vips should differentiate between 8bit sRGB and 16bit sRGB using the
BandFormat
(UCHAR or USHORT) and report the underlying color space which appears to be common for those cases (sRGB for both 8bit and 16bit).By the way I've found a documentation on libvips color interpretation (https://fossies.org/linux/vips/doc/html/libvips-colour.html) which says:
This explanation says that 16bit sRGB images get
VIPS_INTERPRETATION_RGB16
and 8bit sRGB images getVIPS_INTERPRETATION_sRGB
. I think Vips should separate the bit's (8bit, 16bit with UCAHR and USHORT accordingly) from the color space (sRGB in this case)So When the scanner report that each image is sRGB color space, Vips report on different color space for the 16x3bit files although they are actually also sRGB with 16bit per pixel - This insert inconsistencyas our system expect sRGB for the 16bit images and get reported by vips as RGB16.
Thank in advanced.
The text was updated successfully, but these errors were encountered: