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

colour_transform_to Image_type.GREY16 leaves image as 32bit float #83

Open
indridieinarsson opened this issue Nov 1, 2019 · 1 comment
Labels

Comments

@indridieinarsson
Copy link

I've been writing some scripts in the nip2 scripting language to deal with b&w film scans. Those are in 16bit greyscale.
I load it into a nip2 workspace, nip2 says it is "3424x2320 16bit unsigned integer, 1 band, GREY16"

Then I run it through a toolkit I wrote, which does some manipulation (gamma + scaling), which is inherently a floating point operation, so no surprise that the results of that nip2 cell says the image is now: "3424x2320 32bit float, 1 band, GREY16"

However, this is problematic since some of nip2 tools don't work properly on 32bit float images.

In my script, I tried to do conversion : value = colour_transform_to Image_type.GREY16 value2; where value2 is the manipulated image as before (I did reload the script in the meantime). This conversion does not seem to change anything, as the type of the image in the nip2 cell is still declared as "3424x2320 32bit float, 1 band, GREY16".

I also tried to do casts, which also brought nothing.

Is there a bug in the color_transform_to function, or (more likely) am I misunderstanding something here? I'm using nip2 v 8.7.1 compiled against libvips 8.8.3 on a linux machine.

Greetings,
Indriði

@indridieinarsson indridieinarsson changed the title Confusion with image format conversion colour_transform_to Image_type.GREY16 leaves image as 32bit float Nov 1, 2019
@jcupitt
Copy link
Member

jcupitt commented Nov 1, 2019

Hello @indridieinarsson,

This is deliberate: tags like grey16 say how pixel values should be interpreted, not what exact numeric format they are. grey16 just means values in the range 0 - 65535 (2 ** 16 - 1) are black to white, and there's a linear gamma.

If you want a 16-bit numeric format, use (unsigned short) A3 or cast_unsigned_short A3 or Image / Format / 16-bit unsigned.

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

No branches or pull requests

2 participants