Closed
Description
I wanted to generate a histogram as a CSV file for single and multi-channel images. The format I needed was each row represents an intensity, each column represents a channel. This differs from the standard VIPS histogram which is a single row with a column for each intensity value for a single channel only.
My initial approach was to take the histogram and iterate over each element of the histogram which worked great on RGBA (about 4.5 seconds) but for a 2-byte greyscale image, this took about 5 minutes.
The following runs in about 0.07 seconds for RGBA and about 5 seconds for the ushort:
image
.hist_find
.rot90
.bandunfold
.csvsave("histogram.csv", separator: ",")
There may well be a better way, but that worked for me :)
Oh, the only other thing I wish I could do is add column headers but I can live without them.