5 Replies Latest reply on Mar 25, 2009 3:32 PM by Panoholic

    DNK_SDK get pixel value before logaritmic conversion

      Hello
      I need to get pixel value before logaritmic conversion. I use class dng_const_tile_buffer derived form dng_image class for access to pixel value. Image looks like it's tone curve is curve form camera. I need data in linear space. Can somebody help
      Thanks
        • 1. Re: DNK_SDK get pixel value before logaritmic conversion
          sandy_mc Level 3
          You don't give any detail on what's in the dng_image structure at the time, which makes it difficult to answer your question.

          But in general, dng_image can store data that is encoded in different ways - it doesn't have only one format. If you take a look at the dng_validate code, an image goes through three stages - Stage 1 is the raw image from the camera, encoded however the camera did it, Stage two is the linearized image, and stage 3 is the demosaiced image.

          Sandy
          • 2. Re: DNK_SDK get pixel value before logaritmic conversion
            Level 1
            I make my function based on dng_validate. I need pixel value after demosaicing but before logaritmic conversion so I need Stage3Image. I think that solution can be something like this: <br />render.SetToneCurve(linear_curve); <br /><br />I also tryed this for load value but it didn't work :(<br />dng_const_tile_buffer buffer(negative->Stage3Image(),(negative->Stage3Image())->Size());<br /><br />Pecka<br /><br />Here is code of my small function:<br /><br />static uint32 gMaximumSize   = 500;<br />static uint32 gFinalPixelType = ttFloat;<br />static uint32 gMathDataType = ttFloat;<br />static int32 gMosaicPlane = -1;<br />static const dng_color_space *gFinalSpace = &dng_space_sRGB::Get ();<br />static bool gFourColorBayer = false;<br /><br />dng_file_stream stream (*(*argv+1));<br />dng_host host;<br />host.SetMaximumSize   (gMaximumSize  );<br />host.ValidateSizes ();<br /><br />// Read into the negative.<br />AutoPtr<dng_negative> negative;<br />{<br />dng_info info;<br />info.Parse (host, stream);<br />info.PostParse (host);<br />negative.Reset (host.Make_dng_negative ());<br />negative->Parse (host, stream, info);<br />negative->PostParse (host, stream, info);<br />  {<br />  dng_timer timer ("Raw image read time");<br />  negative->ReadStage1Image (host, stream, info);<br />  }<br />}<br /><br />// Build stage 2 image.<br />{<br />dng_timer timer ("Linearization time");<br />negative->BuildStage2Image (host,gMathDataType);<br />}<br /><br />// Build stage 3 image.<br />{<br />dng_timer timer ("Interpolate time");<br />negative->BuildStage3Image (host,gMosaicPlane);<br />}<br /><br />// Render final Image<br />dng_render render (host, *negative);<br />render.SetFinalSpace     (*gFinalSpace);<br />render.SetFinalPixelType (gFinalPixelType);<br /><br />AutoPtr<dng_image> finalImage;<br />{<br />dng_timer timer ("Render time");<br />finalImage.Reset (render.Render ());<br />}<br /><br />dng_const_tile_buffer buffer(*finalImage, finalImage->Size());
            • 3. Re: DNK_SDK get pixel value before logaritmic conversion
              sandy_mc Level 3
              If what you are doing is to look at the image at the "dng_const_tile_buffer buffer(*finalImage, finalImage->Size());" point, then that's post rendering to the sRGB space that you defined in gFinalSpace. sRGB has an appropriately 2.2 gamma.

              So if that's what you are doing, the solution is simple, use a gFinalSpace with a gamma of 1.

              Sandy
              • 4. Re: DNK_SDK get pixel value before logaritmic conversion
                Level 1
                Yes you are right. I changed gamma here :

                real64 dng_function_GammaEncode_sRGB::EvaluateInverse (real64 y)

                and here

                real64 dng_function_GammaEncode_sRGB::Evaluate (real64 x)

                and i think it works.

                Thank you

                Pecka
                • 5. Re: DNK_SDK get pixel value before logaritmic conversion
                  Panoholic Level 2
                  Pecka,

                  good to see that your problem is solved. Now it's time to talk about another aspect:
                  i there is no logarithmic conversion
                  anywhere, nor does an
                  i exponential conversion
                  take place (that too comes up often). The mapping from linear in the so-called "gamma" space is a
                  i power function.