Пример #1
0
// ConstantColors returns a slice of the constant pixel values of all channels within
// either the src image, or the specific channel range of the given ROI.
// If the image does not have constant colors in the given channel range, a nil value
// is returned.
func ConstantColors(src *ImageBuf, opts ...AlgoOpts) []float32 {
	opt := flatAlgoOpts(opts)

	// Determine how big of a slice to allocation,
	// depending on whether they have passed an ROI
	// or not.
	num := src.NumChannels()
	if opt.ROI != nil {
		roi_num := opt.ROI.NumChannels()
		if roi_num < num {
			num = roi_num
		}
	}
	values := make([]float32, num)
	c_ptr := (*C.float)(unsafe.Pointer(&values[0]))

	ok := C.is_constant_color(src.ptr, c_ptr, opt.ROI.validOrAllPtr(), C.int(opt.Threads))
	if !bool(ok) {
		return nil
	}
	return values
}
Пример #2
0
// IsConstantColor returns true if all pixels of src within the ROI have the same values
// (for the subset of channels described by roi)
func IsConstantColor(src *ImageBuf, opts ...AlgoOpts) bool {
	opt := flatAlgoOpts(opts)
	ok := C.is_constant_color(src.ptr, nil, opt.ROI.validOrAllPtr(), C.int(opt.Threads))
	return bool(ok)
}