From 9ab418577d0d4df809871bcf7c02292669e0692b Mon Sep 17 00:00:00 2001 From: n0vad3v Date: Thu, 14 Nov 2024 15:34:19 +0800 Subject: [PATCH] pass into hist_find_ndim --- vips/arithmetic.c | 4 ++-- vips/arithmetic.go | 4 ++-- vips/arithmetic.h | 2 +- vips/image.go | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/vips/arithmetic.c b/vips/arithmetic.c index 824ee673..4e10ae2e 100644 --- a/vips/arithmetic.c +++ b/vips/arithmetic.c @@ -66,8 +66,8 @@ int hist_find(VipsImage *in, VipsImage **out) { return vips_hist_find(in, out, NULL); } -int hist_find_ndim(VipsImage *in, VipsImage **out) { - return vips_hist_find_ndim(in, out, NULL); +int hist_find_ndim(VipsImage *in, VipsImage **out, int bins) { + return vips_hist_find_ndim(in, out, "bins", bins, NULL); } int hist_cum(VipsImage *in, VipsImage **out) { diff --git a/vips/arithmetic.go b/vips/arithmetic.go index 0a60a467..eb7ee155 100644 --- a/vips/arithmetic.go +++ b/vips/arithmetic.go @@ -140,11 +140,11 @@ func vipsHistFind(in *C.VipsImage) (*C.VipsImage, error) { } // https://www.libvips.org/API/current/libvips-arithmetic.html#vips-hist-find-ndim -func vipsHistFindNdim(in *C.VipsImage) (*C.VipsImage, error) { +func vipsHistFindNdim(in *C.VipsImage, bins int) (*C.VipsImage, error) { incOpCounter("histFindNdim") var out *C.VipsImage - if err := C.hist_find_ndim(in, &out); err != 0 { + if err := C.hist_find_ndim(in, &out, C.int(bins)); err != 0 { return nil, handleImageError(out) } diff --git a/vips/arithmetic.h b/vips/arithmetic.h index 17b7c42b..62bea788 100644 --- a/vips/arithmetic.h +++ b/vips/arithmetic.h @@ -17,7 +17,7 @@ int stats(VipsImage *in, VipsImage **out); int maxpos(VipsImage *in, double *out); int minpos(VipsImage *in, double *out); int hist_find(VipsImage *in, VipsImage **out); -int hist_find_ndim(VipsImage *in, VipsImage **out); +int hist_find_ndim(VipsImage *in, VipsImage **out, int bins); int hist_cum(VipsImage *in, VipsImage **out); int hist_norm(VipsImage *in, VipsImage **out); int hist_entropy(VipsImage *in, double *out); diff --git a/vips/image.go b/vips/image.go index 9e566460..956ba470 100644 --- a/vips/image.go +++ b/vips/image.go @@ -1720,8 +1720,9 @@ func (r *ImageRef) HistogramFind() error { return nil } -func (r *ImageRef) HistogramFindNdim() error { - out, err := vipsHistFindNdim(r.image) +// Make a one, two or three dimensional histogram of a 1, 2 or 3 band image. Divide each axis into `bins` bins .. ie. output is 1 x bins, bins x bins, or bins x bins x bins bands. bins defaults to 10. +func (r *ImageRef) HistogramFindNdim(bins int) error { + out, err := vipsHistFindNdim(r.image, bins) if err != nil { return err }