Пример #1
0
// VImageConvolve_ARGB8888 convolves a region of interest within a source image by an M x N kernel, then divides the pixel values by a divisor.
func VImageConvolve_ARGB8888(src, dst *VImageBuffer, tempBuffer []byte, roiX, roiY int, kernel []int16, kernelHeight, kernelWidth, divisor int, backgroundColor [4]uint8, flags VImageFlag) error {
	var tmpBuf unsafe.Pointer
	if tempBuffer != nil {
		tmpBuf = unsafe.Pointer(&tempBuffer[0])
	}
	srcC := src.toC()
	dstC := dst.toC()
	return toError(C.vImageConvolve_ARGB8888(&srcC, &dstC, tmpBuf, C.vImagePixelCount(roiX),
		C.vImagePixelCount(roiY), (*C.int16_t)(&kernel[0]), C.uint32_t(kernelHeight),
		C.uint32_t(kernelWidth), C.int32_t(divisor), (*C.uint8_t)(&backgroundColor[0]), C.vImage_Flags(flags)))
}
Пример #2
0
// Calculates a histogram for a Planar8 image.
func VImageHistogramCalculation_Planar8(src *VImageBuffer, flags VImageFlag) ([]int, error) {
	srcC := src.toC()
	var hist [256]C.vImagePixelCount
	if err := toError(C.vImageHistogramCalculation_Planar8(&srcC, &hist[0], C.vImage_Flags(flags))); err != nil {
		return nil, err
	}
	outHist := make([]int, 256)
	for i, count := range hist {
		outHist[i] = int(count)
	}
	return outHist, nil
}
Пример #3
0
// VImageRichardsonLucyDeConvolve_ARGBFFFF sharpens an ARGBFFFF image by undoing a previous convolution that blurred the image, such as diffraction effects in a camera lens.
func VImageRichardsonLucyDeConvolve_ARGBFFFF(src, dst *VImageBuffer, tempBuffer []byte, roiX, roiY int, kernel, kernel2 []float32, kernelHeight, kernelWidth, kernelHeight2, kernelWidth2 int, backgroundColor [4]float32, iterationCount int, flags VImageFlag) error {
	var tmpBuf unsafe.Pointer
	if tempBuffer != nil {
		tmpBuf = unsafe.Pointer(&tempBuffer[0])
	}
	var kernel2Ptr *C.float
	if kernel2 != nil {
		kernel2Ptr = (*C.float)(&kernel2[0])
	}
	srcC := src.toC()
	dstC := dst.toC()
	return toError(C.vImageRichardsonLucyDeConvolve_ARGBFFFF(&srcC, &dstC, tmpBuf, C.vImagePixelCount(roiX),
		C.vImagePixelCount(roiY), (*C.float)(&kernel[0]), kernel2Ptr, C.uint32_t(kernelHeight),
		C.uint32_t(kernelWidth), C.uint32_t(kernelHeight2), C.uint32_t(kernelWidth2), (*C.float)(&backgroundColor[0]),
		C.uint32_t(iterationCount), C.vImage_Flags(flags)))
}
Пример #4
0
// Calculates histograms for each channel of an ARGB8888 image.
func VImageHistogramCalculation_ARGB8888(src *VImageBuffer, flags VImageFlag) ([4][]int, error) {
	srcC := src.toC()
	var hist [4][256]C.vImagePixelCount
	var histPtrs [4]*C.vImagePixelCount
	for i := 0; i < 4; i++ {
		histPtrs[i] = &hist[i][0]
	}
	if err := toError(C.vImageHistogramCalculation_ARGB8888(&srcC, &histPtrs[0], C.vImage_Flags(flags))); err != nil {
		return [4][]int{}, err
	}
	var outHist [4][]int
	for i, h := range hist {
		outHist[i] = make([]int, 256)
		for j, count := range h {
			outHist[i][j] = int(count)
		}
	}
	return outHist, nil
}
Пример #5
0
// VImageAlphaBlend_ARGB8888 performs nonpremultiplied alpha compositing of two ARGB8888 images, placing the result in a destination buffer.
func VImageAlphaBlend_ARGB8888(srcTop, srcBottom, dst *VImageBuffer, flags VImageFlag) error {
	srcTopC := srcTop.toC()
	srcBottomC := srcBottom.toC()
	dstC := dst.toC()
	return toError(C.vImageAlphaBlend_ARGB8888(&srcTopC, &srcBottomC, &dstC, C.vImage_Flags(flags)))
}
Пример #6
0
// VImagePremultipliedConstAlphaBlend_ARGB8888 performs premultiplied alpha compositing of two ARGB8888 images, using a single alpha value for the whole image and placing the result in a destination buffer.
func VImagePremultipliedConstAlphaBlend_ARGB8888(srcTop *VImageBuffer, constAlpha uint8, srcBottom, dst *VImageBuffer, flags VImageFlag) error {
	srcTopC := srcTop.toC()
	srcBottomC := srcBottom.toC()
	dstC := dst.toC()
	return toError(C.vImagePremultipliedConstAlphaBlend_ARGB8888(&srcTopC, C.Pixel_8(constAlpha), &srcBottomC, &dstC, C.vImage_Flags(flags)))
}
Пример #7
0
// VImagePermuteChannels_ARGB8888 reorders the channels in an ARGB8888 image.
//
// permuteMap:
//     An array of four 8-bit integers with the values 0, 1, 2, and 3,
//     in some order. Each value specifies a plane from the source image
//     that should be copied to that plane in the destination image. 0
//     denotes the alpha channel, 1 the red channel, 2 the green channel,
//     and 3 the blue channel. The following figure shows the result of
//     using a permute map shows values are (0, 3, 2, 1). The data in the
//     alpha and green channels remain the same, but the data in the source
//     red channel maps to the destination blue channel while the data in
//     the source blue channel maps to the destination red channel.
func VImagePermuteChannels_ARGB8888(src, dst *VImageBuffer, permuteMap [4]uint8, flags VImageFlag) error {
	srcC := src.toC()
	dstC := dst.toC()
	return toError(C.vImagePermuteChannels_ARGB8888(&srcC, &dstC, (*C.uint8_t)(&permuteMap[0]), C.vImage_Flags(flags)))
}