ciimage

CIImage extent in pixels or points?

隐身守侯 提交于 2021-02-07 17:24:36
问题 I'm working with a CIImage, and while I understand it's not a linear image, it does hold some data. My question is whether or not a CIImage's extent property returns pixels or points? According to the documentation, which says very little, it's working space coordinates. Does this mean there's no way to get the pixels / points from a CIImage and I must convert to a UIImage to use the .size property to get the points? I have a UIImage with a certain size, and when I create a CIImage using the

How to not cause dark gray color to be transparent removing background from image

好久不见. 提交于 2020-04-13 17:10:11
问题 I'm having an issue where when I try to remove the green from an image (in this case the image background) but all the dark grays (within the part of the image I want to keep) become semi-transparent. I am unsure why, would like some advice on how to: func chromaKeyFilter(fromHue: CGFloat, toHue: CGFloat) -> CIFilter? { let size = 64 var cubeRGB = [Float]() for z in 0 ..< size { let blue = CGFloat(z) / CGFloat(size-1) for y in 0 ..< size { let green = CGFloat(y) / CGFloat(size-1) for x in 0 .

CIAdditionCompositing giving incorrect effect

风格不统一 提交于 2020-04-13 05:39:25
问题 I am trying to create an image by averaging several other images. To achieve this, I first darken each image by a factor equivalent to the number of images I am averaging: func darkenImage(by multiplier: CGFloat) -> CIImage? { let divImage = CIImage(color: CIColor(red: multiplier, green: multiplier, blue: multiplier)) let divImageResized = divImage.cropped(to: self.extent) //Set multiplier image to same size as image to be darkened if let divFilter = CIFilter(name: "CIMultiplyBlendMode",

CIAdditionCompositing giving incorrect effect

感情迁移 提交于 2020-04-13 05:39:11
问题 I am trying to create an image by averaging several other images. To achieve this, I first darken each image by a factor equivalent to the number of images I am averaging: func darkenImage(by multiplier: CGFloat) -> CIImage? { let divImage = CIImage(color: CIColor(red: multiplier, green: multiplier, blue: multiplier)) let divImageResized = divImage.cropped(to: self.extent) //Set multiplier image to same size as image to be darkened if let divFilter = CIFilter(name: "CIMultiplyBlendMode",

rotate CIImage around center with CIFilter

别说谁变了你拦得住时间么 提交于 2020-03-28 04:15:13
问题 I'm trying to rotate the pixel data of a CMSampleBuffer (coming from the camera) and display it in a UIImageView. I Don't want to rotate the view itself. It has to be the actual pixel data. I grab the feed, convert it to a CIImage and with a CIFilter I rotate it. I'm having trouble with setting the point around which it has to rotate. Right now it rotates around the lower left point. I want to rotate it around its center. func captureOutput(_ captureOutput: AVCaptureOutput!,

How to extract dominant color from CIAreaHistogram?

泪湿孤枕 提交于 2020-01-13 06:04:33
问题 I am looking to analyze the most dominant color in a UIImage on iOS (color present in the most pixels) and I stumbled upon Core Image's filter based API, particularly CIAreaHistogram. It seems like this filter could probably help me but I am struggling to understand the API. Firstly it says the output of the filter is a one-dimensional image which is the length of your input-bins and one pixel in height. How do I read this data? I basically want to figure out the color-value with the highest

Adding filters to video with AVFoundation (OSX) - how do I write the resulting image back to AVWriter?

假装没事ソ 提交于 2020-01-10 02:07:16
问题 Setting the scene I am working on a video processing app that runs from the command line to read in, process and then export video. I'm working with 4 tracks. Lots of clips that I append into a single track to make one video. Let's call this the ugcVideoComposition. Clips with Alpha which get positioned on a second track and using layer instructions, is set composited on export to play back over the top of the ugcVideoComposition. A music audio track. An audio track for the