Determining value of brightest pixel in most recent image. - page 2 - Script Writing - CHDK Forum

Determining value of brightest pixel in most recent image.

  • 16 Replies
  • 5519 Views
*

Offline reyalp

  • ******
  • 12151
Re: Determining value of brightest pixel in most recent image.
« Reply #10 on: 07 / July / 2009, 20:33:09 »
Advertisements
get_histo_range should tell you the percentage of pixels whose value fall within the given range. These are raw pixels so it's looking red, green and blue elements individually.

Note that you will probably get some values on the high end due to hot pixels, and this will increase as things warm up. Since it's an integer percentage, they should get rounded off unless there's quite a few of them.
Don't forget what the H stands for.

*

Offline Atnas

  • *
  • 29
Re: Determining value of brightest pixel in most recent image.
« Reply #11 on: 08 / July / 2009, 02:27:27 »
I have noise reduction enabled (dark frame subtraction)

Does the get_histo range go off the raw before noise reduction?
I think that could explain my high values in the darker areas
A710 - SD1000(IXUS70)

*

Offline reyalp

  • ******
  • 12151
Re: Determining value of brightest pixel in most recent image.
« Reply #12 on: 08 / July / 2009, 19:55:19 »
I have noise reduction enabled (dark frame subtraction)

Does the get_histo range go off the raw before noise reduction?
I think that could explain my high values in the darker areas
No, it should happen after dark frame. Note that unless you've forced dark frame subtraction, it only happens after fairly long exposures (3 sec or longer ISTR). In any case, it's not perfect.
Don't forget what the H stands for.

*

Offline Mac

  • *
  • 40
Re: Determining value of brightest pixel in most recent image.
« Reply #13 on: 15 / July / 2009, 21:06:46 »


*

Offline Atnas

  • *
  • 29
Re: Determining value of brightest pixel in most recent image.
« Reply #14 on: 21 / July / 2009, 22:21:28 »
Hey Mac

Would you mind posting your script?
Would love to see it, and play around with it :)

Glad there are no severe errors, as this is afterall my first script :)

To fix the EV<1 i think that this:
Code: [Select]
if w=1 then E=E*-1

if e=0 then print E,"EV"
if e=1 then print E,"1/3 EV"
if e=2 then print E,"2/3 EV"
Should be replaced with:
Code: [Select]
if e=0 then if w=0 then print E,"EV"
if e=1 then if w=0 then print E,"1/3 EV"
if e=2 then if w=0 then print E,"2/3 EV"

if e=0 then if w=1 then print "-";E,"EV"
if e=1 then if w=1 then print "-";E,"1/3 EV"
if e=2 then if w=1 then print "-";E,"2/3 EV"
A710 - SD1000(IXUS70)

*

Offline Mac

  • *
  • 40
Re: Determining value of brightest pixel in most recent image.
« Reply #15 on: 22 / July / 2009, 11:09:29 »
Hi Atnas!
As you can see, I'm a "Rookie" also.  Am hesitant to post a script which are only slight modifications of already quite fundtional one.  Hope I don't just add clutter and probably intorduce more errors.
This said, hear goes for what it's worth).

--[[@title AutoHDR.lua
-- Attempt to automate process of creating multiple photos for HDR combining
-- Original by Atnes
-- Converted to LUA and modified by Mac on 07/10/2009
@param a EXP Step
@default a 1
@param b +EXP Step (x/3)
@default b 0
@param c Start Delay(sec)
@default c 3
@param d Bright Limit(29-1023)
@default d 150
@param e Dark Limit(29-1023)
@default e 100
@param f DF Sub(auto=0,off=1,on=2)
@default f 2
@param g Meter(0=ev,1=spot,2=cnt)
@default g 2
]]
function Log(name)
   -- Prevents overwriting existing log
   local i = 0
   repeat
      i = i + 1
      num = 1000 + i
      numstr = string.sub(tostring(num),-3)
      path = "A/CHDK/LOGS/"
      filename = path..name..numstr
      res,msg = io.open(filename)
      until not res
   io.output(io.open(filename,"a+"))
   end

function Delay(sec)
   repeat
      cls()
      print("Starting in ", sec, "sec")
      sleep(960)
      sec = sec - 1
      until sec==0
      end

function Record()
   io.write("AutoHDR Script\n")
   io.write(os.date("%m/%d/%Y %X\n"))
   io.write("Uncorrected photo: "..photo.."\n")
   Bv=get_bv96() Av=get_av96() Sv=get_sv96() Tv=get_tv96()
   io.write("Bv= "..Bv.." Sv= "..Sv.." Av= "..Av.." Tv= "..Tv.."\n")
   io.close()
   end

function Shot()
   sleep(100)
   click("shoot_full")
   repeat
      sleep(10)
      until get_shooting()~=true
   sleep(500)
   Number_of_Shots = Number_of_Shots + 1
   photo = get_exp_count()
   end

function Initial_Shot()
   set_aflock(0)
   press("shoot_half")
   repeat
      sleep(10)
      until get_shooting()==true
   release("shoot_half")
   set_aflock(1)
   Shot()
   Start_Photo=photo
   end

function Record_INFO()
   io.output(io.open(filename,"a+"))
   sign = 1
   Delta_EXP = Delta_EXP/32
   --if Delta_EXP is negative, change to positive and set sign to -1
   if Delta_EXP < 0 then sign = -1 Delta_EXP = sign*Delta_EXP end
   E = Delta_EXP/3
   E = 3*Delta_EXP
   third = Delta_EXP-E
   E = sign*E/3
   if third==0 then print(E,"EV") io.write(photo.." h= "..h.." "..E.."EXP\n") end
   if third==1 then print(E,"1/3 EV") io.write(photo.." h= "..h.." "..E.."1/3 EXP\n") end
   if third==2 then print(E,"2/3 EV") io.write(photo.." h= "..h.." "..E.."2/3 EXP\n") end
   io.close()
   end

function Bright_Areas()
   cls()
   print("Light area correction")
   Bright_Tv = Tv
   --Decrease exposure by EXP_step
   repeat
      Bright_Tv = Bright_Tv + EXP_Step
      set_tv96_direct(Bright_Tv)
      Delta_EXP = Tv-Bright_Tv
      Shot()
      --Check for bright pixels in the histogram
      h = get_histo_range(d,1023)
      --Display exposure difference from origrinal (Delta_EXP)
      Record_INFO()
      sleep(100)
      --If too bright, use shorter exposure for darker image
      until h==0
   end

function Dark_Areas()
   cls()
   print("Dark area correction")
   Dark_Tv = Tv
   repeat
      --Increase exposure by EXP_step
      Dark_Tv = Dark_Tv - EXP_Step
      set_tv96_direct(Dark_Tv)
      Delta_EXP = Tv-Dark_Tv
      Shot()
      --Check for dark pixels in the histogram
      h = get_histo_range(0,e)
      --Display exposure difference from origrinal (Delta_EXP)
      Record_INFO()
      sleep(100)
      --If too dark, use longer exposure for brighter image
      until h==0
   end

function Log_Summary()
   io.output(io.open(filename,"a+"))
   io.write("Total number of pics: "..Number_of_Shots.."\n")
   io.write("Photos taken: "..Start_Photo.." to "..photo.."\n")
   Range_Tv = (Bright_Tv - Dark_Tv)/96
   io.write("Total exposure range(EXP): "..Range_Tv.."\n")
   io.close()
   end

--Script Begins
log_name="AutoHDR_"
Log(log_name)
Delay(c)
   -- Set exposure mode (0 = evaluation, 1 = spot, 2 = center weighted)
   if get_propset()==1 then set_prop(9,g) else set_prop(155,g) end
   shot_histo_enable(1)
   set_raw_nr(f)
   EXP_Step=96*a+32*b
   Number_of_Shots=0
Initial_Shot()
Record()
Bright_Areas()
Dark_Areas()
Log_Summary()
   set_aflock (0)
   set_raw_nr(0)

*

Offline Mac

  • *
  • 40
Re: Determining value of brightest pixel in most recent image.
« Reply #16 on: 26 / July / 2009, 21:24:11 »
This is sort of a shotgun approach to HDR photography.
Would be nice to be able to take one photo and let the script take one or two additional shots to fill in the over and/or under exposed areas (some kind of logic to relate histogram INFO with camera exposure adjustment.)

 

Related Topics