Apply LUT (lookup table) on image (Swift + Xcode)2019 Community Moderator ElectionInvert a LUT (lookup table)Lookup Table/s for ImagesC++ exp LUT (lookup table)OS X, Cocoa: How to highlight burned-out areas of a photo?Swift to Objective-C header not created in Xcode 6Loading/Downloading image from URL on SwiftUIScrollView cannot display image either in Portrait or Landscape modeApply openCV Look Up Table (LUT) to an imageOptimization ideas : apply a LUT (lookup table) on an imageHow to apply LUT (from .png) to an image? (Swift + Xcode)

Unfrosted light bulb

What can I do if I am asked to learn different programming languages very frequently?

What does Jesus mean regarding "Raca," and "you fool?" - is he contrasting them?

Is it insecure to send a password in a `curl` command?

Hausdorff dimension of the boundary of fibres of Lipschitz maps

What does "^L" mean in C?

Why didn't Héctor fade away after this character died in the movie Coco?

What is the term when voters “dishonestly” choose something that they do not want to choose?

Generic TVP tradeoffs?

Suggestions on how to spend Shaabath (constructively) alone

Help prove this basic trig identity please!

Would it be believable to defy demographics in a story?

How does 取材で訪れた integrate into this sentence?

In what cases must I use 了 and in what cases not?

두음법칙 - When did North and South diverge in pronunciation of initial ㄹ?

Why are there no stars visible in cislunar space?

Deletion of copy-ctor & copy-assignment - public, private or protected?

How to generate binary array whose elements with values 1 are randomly drawn

Asserting that Atheism and Theism are both faith based positions

Probably overheated black color SMD pads

Worshiping one God at a time?

Have the tides ever turned twice on any open problem?

Recruiter wants very extensive technical details about all of my previous work

What does Deadpool mean by "left the house in that shirt"?



Apply LUT (lookup table) on image (Swift + Xcode)



2019 Community Moderator ElectionInvert a LUT (lookup table)Lookup Table/s for ImagesC++ exp LUT (lookup table)OS X, Cocoa: How to highlight burned-out areas of a photo?Swift to Objective-C header not created in Xcode 6Loading/Downloading image from URL on SwiftUIScrollView cannot display image either in Portrait or Landscape modeApply openCV Look Up Table (LUT) to an imageOptimization ideas : apply a LUT (lookup table) on an imageHow to apply LUT (from .png) to an image? (Swift + Xcode)










0















I want to edit an image with a LUT filter as a CIFilter to edit the color of the image. Unfortunately, I stumble with the conversion in Swift. When I execute the code, the processedImage results in nil at the end.



Here is my code from my ViewController:



Example Image: LUT.png



let nameLUT = "LUT.png"
let inputImage = CIImage(image: image)
let context = CIContext(options: nil)

if let currentFilter = CIFilter(name: nameLUT)

let beginImage = inputImage
currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
currentFilter.setValue(0.5, forKey: kCIInputIntensityKey)

if let output = currentFilter.outputImage
if let cgimg = context.createCGImage(output, from: output.extent)
let processedImage = UIImage(cgImage: cgimg)





Here is the implementation of the functions to CIFilter from my .swift extension:



extension CIFilter {
func colorCubeFilterFromLUT(name : String) -> CIFilter?

class func getBytesFromImage(from image:CGImage?) -> [UInt8]?
print("Filter: func getBytesFromImage")
var pixelValues: [UInt8]?
if let imageRef = image CGBitmapInfo.byteOrder32Little.rawValue
let colorSpace = CGColorSpaceCreateDeviceRGB()
var intensities = [UInt8](repeating: 0, count: totalBytes)

let contextRef = CGContext(data: &intensities, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
contextRef?.draw(imageRef, in: CGRect(x: 0.0, y: 0.0, width: CGFloat(width), height: CGFloat(height)))

pixelValues = intensities

return pixelValues!










share|improve this question




























    0















    I want to edit an image with a LUT filter as a CIFilter to edit the color of the image. Unfortunately, I stumble with the conversion in Swift. When I execute the code, the processedImage results in nil at the end.



    Here is my code from my ViewController:



    Example Image: LUT.png



    let nameLUT = "LUT.png"
    let inputImage = CIImage(image: image)
    let context = CIContext(options: nil)

    if let currentFilter = CIFilter(name: nameLUT)

    let beginImage = inputImage
    currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
    currentFilter.setValue(0.5, forKey: kCIInputIntensityKey)

    if let output = currentFilter.outputImage
    if let cgimg = context.createCGImage(output, from: output.extent)
    let processedImage = UIImage(cgImage: cgimg)





    Here is the implementation of the functions to CIFilter from my .swift extension:



    extension CIFilter {
    func colorCubeFilterFromLUT(name : String) -> CIFilter?

    class func getBytesFromImage(from image:CGImage?) -> [UInt8]?
    print("Filter: func getBytesFromImage")
    var pixelValues: [UInt8]?
    if let imageRef = image CGBitmapInfo.byteOrder32Little.rawValue
    let colorSpace = CGColorSpaceCreateDeviceRGB()
    var intensities = [UInt8](repeating: 0, count: totalBytes)

    let contextRef = CGContext(data: &intensities, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
    contextRef?.draw(imageRef, in: CGRect(x: 0.0, y: 0.0, width: CGFloat(width), height: CGFloat(height)))

    pixelValues = intensities

    return pixelValues!










    share|improve this question


























      0












      0








      0








      I want to edit an image with a LUT filter as a CIFilter to edit the color of the image. Unfortunately, I stumble with the conversion in Swift. When I execute the code, the processedImage results in nil at the end.



      Here is my code from my ViewController:



      Example Image: LUT.png



      let nameLUT = "LUT.png"
      let inputImage = CIImage(image: image)
      let context = CIContext(options: nil)

      if let currentFilter = CIFilter(name: nameLUT)

      let beginImage = inputImage
      currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
      currentFilter.setValue(0.5, forKey: kCIInputIntensityKey)

      if let output = currentFilter.outputImage
      if let cgimg = context.createCGImage(output, from: output.extent)
      let processedImage = UIImage(cgImage: cgimg)





      Here is the implementation of the functions to CIFilter from my .swift extension:



      extension CIFilter {
      func colorCubeFilterFromLUT(name : String) -> CIFilter?

      class func getBytesFromImage(from image:CGImage?) -> [UInt8]?
      print("Filter: func getBytesFromImage")
      var pixelValues: [UInt8]?
      if let imageRef = image CGBitmapInfo.byteOrder32Little.rawValue
      let colorSpace = CGColorSpaceCreateDeviceRGB()
      var intensities = [UInt8](repeating: 0, count: totalBytes)

      let contextRef = CGContext(data: &intensities, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
      contextRef?.draw(imageRef, in: CGRect(x: 0.0, y: 0.0, width: CGFloat(width), height: CGFloat(height)))

      pixelValues = intensities

      return pixelValues!










      share|improve this question
















      I want to edit an image with a LUT filter as a CIFilter to edit the color of the image. Unfortunately, I stumble with the conversion in Swift. When I execute the code, the processedImage results in nil at the end.



      Here is my code from my ViewController:



      Example Image: LUT.png



      let nameLUT = "LUT.png"
      let inputImage = CIImage(image: image)
      let context = CIContext(options: nil)

      if let currentFilter = CIFilter(name: nameLUT)

      let beginImage = inputImage
      currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
      currentFilter.setValue(0.5, forKey: kCIInputIntensityKey)

      if let output = currentFilter.outputImage
      if let cgimg = context.createCGImage(output, from: output.extent)
      let processedImage = UIImage(cgImage: cgimg)





      Here is the implementation of the functions to CIFilter from my .swift extension:



      extension CIFilter {
      func colorCubeFilterFromLUT(name : String) -> CIFilter?

      class func getBytesFromImage(from image:CGImage?) -> [UInt8]?
      print("Filter: func getBytesFromImage")
      var pixelValues: [UInt8]?
      if let imageRef = image CGBitmapInfo.byteOrder32Little.rawValue
      let colorSpace = CGColorSpaceCreateDeviceRGB()
      var intensities = [UInt8](repeating: 0, count: totalBytes)

      let contextRef = CGContext(data: &intensities, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
      contextRef?.draw(imageRef, in: CGRect(x: 0.0, y: 0.0, width: CGFloat(width), height: CGFloat(height)))

      pixelValues = intensities

      return pixelValues!







      swift image filter xcode10 lookup-tables






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 6 at 22:12









      Lauren Van Sloun

      1,02921219




      1,02921219










      asked Mar 6 at 17:40









      Timothy C.Timothy C.

      11




      11






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029167%2fapply-lut-lookup-table-on-image-swift-xcode%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029167%2fapply-lut-lookup-table-on-image-swift-xcode%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко