Skip to content
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

OpenSlide images aren't automatically converted from ARGB #11

Closed
bgilbert opened this issue Apr 2, 2012 · 8 comments
Closed

OpenSlide images aren't automatically converted from ARGB #11

bgilbert opened this issue Apr 2, 2012 · 8 comments

Comments

@bgilbert
Copy link
Contributor

bgilbert commented Apr 2, 2012

Reading an OpenSlide image produces ARGB image data, which doesn't display correctly in nip2 and causes vips openslideload to write output images with incorrect color channels. There's also no hint in the image header (e.g. VipsInterpretation?) that im_argb2rgba is needed.

Is this the correct behavior? I can understand that VIPS may not want to mangle channels without explicit instructions, but it does mean that the most straightforward approaches to loading slides will always be wrong.

(cc: @agoode)

@jcupitt
Copy link
Member

jcupitt commented Apr 4, 2012

This commit makes it a bit more automatic:

jcupitt@78b5ad5

This adds a new coding type for ARGB (meaning Cairo-style argb). Operations like flip and crop will work on ARGB-coded images, but things like arithmetic will fail until you decode with argb2rgba. It will convert automatically for file save operations. There's a similar commit on nip2 master to make it argb2rgba for you.

Maybe this isn't the best approach though. I modelled it on the behaviour with Radiance (HDR) images, where it makes sense because you often want to manipulate a rad image without going through float. But openslide does not support write, so perhaps there's no reason for vips to support Cairo coding? Maybe openslide read should simply always decode.

@jcupitt
Copy link
Member

jcupitt commented Apr 4, 2012

I've reverted that commit. I'll put the argb -> rgba stuff back into openslide2vips, it makes more sense since we never want to expose argb format really

@bgilbert
Copy link
Contributor Author

bgilbert commented Apr 4, 2012

Sounds good to me. Is this change likely to make it into a 7.28.x stable release?

@jcupitt
Copy link
Member

jcupitt commented Apr 4, 2012

It sounds rather intrusive :-( but things do seem badly broken right now.

@jcupitt
Copy link
Member

jcupitt commented Apr 10, 2012

libvips/7.28 HEAD now has a redone openslide read, here's the commit:

jcupitt@57cf901

it seems to work for me, hopefully. If you have time to test (esp. with images with an interesting alpha channel) that would be fantastic. I'll do a new 7.28 including this patch in a few days.

@bgilbert
Copy link
Contributor Author

It works for me, thanks.

(What is the syntax for passing loader arguments to nip2? nip2 CMU-1.mrxs[associated=label] doesn't seem to work.)

@jcupitt
Copy link
Member

jcupitt commented Apr 11, 2012

Great, thanks for testing, I'll close the issue.

The openslide loader only supports vips8 arguments, and nip2 is going to stay on the vips7 API for a while yet. Supporting vips7 loader args would involve adding some code to:

https://github.com/jcupitt/libvips/blob/master/libvips/deprecated/im_openslide2vips.c

See the vips7 tiff loader for an example:

https://github.com/jcupitt/libvips/blob/master/libvips/deprecated/im_tiff2vips.c

Or I guess your original patch would have had this. I'll have a look.

@jcupitt jcupitt closed this as completed Apr 11, 2012
@jcupitt
Copy link
Member

jcupitt commented Apr 11, 2012

This commit to 7.28 adds :level,associated options to the vips7 api for openslide load:

jcupitt@3540e3e

$ header CMU-2.svs
CMU-2.svs: 19500x7615 uchar, 4 bands, rgb VipsImage (0x236a060)
$ header CMU-2.svs:2
CMU-2.svs:2: 4875x1903 uchar, 4 bands, rgb VipsImage (0x244c060)
$ header CMU-2.svs:,label
CMU-2.svs:,label: 387x463 uchar, 4 bands, rgb VipsImage (0xa2d060)
$ header CMU-2.svs:2,label
CMU-2.svs:2,label: 387x463 uchar, 4 bands, rgb VipsImage (0x1b23060)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants