Replies: 22 comments
-
Hello again, For CMYK to RGB specifically I think I would try to make an ICC profile. For the general case, libvips only has 1D lookup, but of course you can turn n-dimensional lookup into 1D by unpacking the dimensions. How big (number of entries) is this 4D table? |
Beta Was this translation helpful? Give feedback.
-
Dear jcupitt, thx for the quick response. We want to do spectral math on the image. Hence ICC transformation does not work here. |
Beta Was this translation helpful? Give feedback.
-
Then I'd load the LUT as a huge 1D image (1 x 33 ** 4 pixels), compute an index image from your CMYK by scaling, multiplying and adding, then map it. You'll need a uint32 index, of course. I suppose you'll want piecewise linear interpolation of the LUT? Just repeat 8 times and sum and scale by the residuals. Tetrahedral interpolation would probably be faster (you only need 4 lookups), if you have the patience to implement that.
|
Beta Was this translation helpful? Give feedback.
-
oh wow - thx - We will look at it. |
Beta Was this translation helpful? Give feedback.
-
Hi, I created a new matrix with 31 * 3 entries and applied it to a spectral VipsImage with 31 bands per pixel: |
Beta Was this translation helpful? Give feedback.
-
that is the actual code, the asterisks got removed before. What exactly is the third parameter in the ..new_matrix.. routine for? |
Beta Was this translation helpful? Give feedback.
-
still no asterisks, it should be (asterisk)m and 3 (asterisk) bands |
Beta Was this translation helpful? Give feedback.
-
On github, put three backticks on a line to start a block of code. You can hint the programming language too and you'll get syntax highlighting. Try this:
To get: VipsImage *m = vips_image_new_matrix_from_array( bands, 3, coeffs, 3*bands );
vips_recomb(orgVI, &orgVI, m, NULL); |
Beta Was this translation helpful? Give feedback.
-
/* compile with:
*
* g++ -g -Wall try310.cpp `pkg-config vips-cpp --cflags --libs`
*
*/
#include <vips/vips8>
using namespace vips;
int
main(int argc, char **argv)
{
if (VIPS_INIT (argv[0]))
return -1;
VImage x = VImage::new_from_file (argv[1]);
VImage mat = VImage::new_matrixv (3, 3,
0.8951, 0.2664, -0.1614,
-0.7502, 1.7135, 0.0367,
0.0389, -0.0685, 1.0296);
x = x.recomb (mat);
x.write_to_file (argv[2]);
return 0;
} |
Beta Was this translation helpful? Give feedback.
-
thanks, John, sorry for the newbie mistakes. does new_matrixv stand for verbose, and if I use new_matrix I can pass an array of mine? what about the grayscale result of mine? |
Beta Was this translation helpful? Give feedback.
-
You can use x = x.copy(VImage::option()->
set("interpretation", VIPS_INTERPRETATION_XYZ)); Like numpy, libvips images are just big arrays. The interpretation tag is a hint about how pixels should be interpreted, it doesn't affect processing (except in a few cases). |
Beta Was this translation helpful? Give feedback.
-
The There are other constructors too, have a look at the header. You probably need static VImage
new_matrix( int width, int height, double *array, int size ) |
Beta Was this translation helpful? Give feedback.
-
that works, may I still ask, what the size parameter is for? Isn't the matrix defined by width and height? |
Beta Was this translation helpful? Give feedback.
-
Yes, it's just a doublecheck. Yes, you can set XYZ at the PCS space, so you can convert to it from device space (if that's what you mean). libvips has a couple of built-in profiles too: srgb, cmyk and none. y = x.icc_import(pcs="xyz") libvips also has it's own XYZ <-> anything converter which should be faster and more accurate than lcms. It's what gets used for LAB -> XYZ conversion, for example. y = x.colourspace("xyz") |
Beta Was this translation helpful? Give feedback.
-
when I try icc_import(pcs="xyz") I get undeclared identifier 'pcs' |
Beta Was this translation helpful? Give feedback.
-
I am trying to convert my XYZ data to the current monitor profile |
Beta Was this translation helpful? Give feedback.
-
I have the path to the current system profile of the active monitor, but need an XYZ profile as input profile |
Beta Was this translation helpful? Give feedback.
-
That was python, in C++ it'd be: VImage device_space = xyz.icc_export(VImage::option()
->set("pcs", "xyz")
->set("output-profile", "/some/path.icm")
); Use |
Beta Was this translation helpful? Give feedback.
-
Your XYZ needs to be D65, btw. |
Beta Was this translation helpful? Give feedback.
-
that did work, I had sucessfully tried this before: |
Beta Was this translation helpful? Give feedback.
-
one last question about this: what is the internal range of XYZ values in VIPS? |
Beta Was this translation helpful? Give feedback.
-
It's just D65 XYZ, so Y is 0-100, X is 0-95 I think, Z is 0-108 (from memory). But they are floats, so of course you can use values way outside that range. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
How can I transform a 4 channel image (e.g. CMYK TIFF)
through a 4D Lut, e.g. into a 3 channel image (RGB)?
Are 4D Luts supported in VIPS?
Regards
Beta Was this translation helpful? Give feedback.
All reactions