locked
special thanks to : Litdev and NaochanON 10 Zones Analyzer final version ! Y.Leduc RRS feed

  • General discussion

  • ' Program by Yvan Leduc     March 21 th 2016  program no: GRM913

    Following LitDev recommendations (see below) I have modified the routine by using the ElseIf statement, which I didn't, and thanks to the good advice of LitDev I understood how to use it.

    For counting of numbers of pixels per Zones became an Option, I add a -

    pixel count click here - button, so we went from 12 to 6 seconds of time processing !, I am very very happy. !!!

    I add a line not necessary, but I like the visual effect of it, to see the transition from the color image to grayscaling down to black and white,  like this:

    ' WITH helps collaboration and special thanks to :  Litdev
    ' WITH helps collaboration and special thanks to :  NaochanON
    ' special thanks to LitDev extension beta version
    ' without the Microsoft team small basic supports, my program would not have been improve to be faster and better build.
    ' thanks to you guys,    you are PRO's   !!!!

    ' it's important to know how much pixels (count) in the extreme Zone Scale like in Zone X and 0 that's why my new version give a blue color for Zone 0 and red for Zone 10.

    time for processing: 7 seconds.

    ( my first version in last October, took 30 minutes to do the same job , now in 12 sec. !!!!! )

    here is the code program no: GRM913

    to sum up : this program do this: very helpful for photography .

    (1) it opens an image
    (2) it transforms into a black and white (LDImage.EffectGray (image))
    (3) it decomposes image in 10 areas of density.
    (4) recolors with a specific color the 10 areas analyzed.

    (5) redraws the image

    so you can see where are your overexposed areas of a picture : in red

    so you can see where are your underexposed areas of a picture : in blue

    so you can see the highest highlights that have preserve details : Zone VIII    colors[16]="#FFF0F0C8"

    so you can see the lowest lowlights that have preserve details :     Zone III      colors[6]="#FF373360"

    here is a screen capture:


    • Edited by YLedEditor Monday, March 21, 2016 5:31 PM new version GRM913
    • Changed type litdev Tuesday, March 22, 2016 9:11 PM
    Saturday, March 19, 2016 8:31 PM
    Answerer

All replies

  • Nice job.

    You can shave another  10 to 20% off by:

    a) since it is grey scale, just test one colour

    ZoneValue= ldmath.Base2Decimal("FF",16)/20

    and

    pixel = text.GetSubTextToEnd(LDImage.GetWorkingImagePixel(image,i,j),8)

    b) use ElseIf to not check all zones when you have found one - or just not calculate these stats (only used for reporting).  Also using ElseIf you don't need to check < and >.

    Sub Zones_pixels_count
      ' zone X
      If Zone=20 then   
        zoneX=zoneX+1                                 
      ElseIf Zone>15 then   
        zoneIX=zoneIX+1                                 
      ElseIf Zone>12 then
        zoneVIII=zoneVIII+1                                 
      ElseIf Zone>9 then
        zoneVII=zoneVII+1                                 
      ElseIf Zone>8 then  
        zoneVI=zoneVI+1                                 
      ElseIf Zone>5 then  
        zoneV=zoneV+1                                 
      ElseIf Zone=4 then   
        zoneIV=zoneIV+1                                 
      ElseIf Zone=3 then   
        zoneIII=zoneIII+1                                 
      ElseIf Zone=2 then   
        zoneII=zoneII+1                                 
      ElseIf Zone>0 then   
        zoneI=zoneI+1                                 
      Else  
        zoneO=zoneO+1                                 
      endif
    endsub

    To go faster still you would need to do it all directly in an extension method, but that would be very specific.

    Or you could reduce the image size that you do the work on, LDImage.Resize etc. Somethng like this, PRT766-0.



    • Edited by litdev Saturday, March 19, 2016 11:10 PM
    Saturday, March 19, 2016 11:04 PM
  • Hi Yvan

    I made an extension and program is WGT159  (it took 360msec)  .

    You can download from here.  (VS project. copy  SBext.dll and SBext.xml into  smallbasic\Lib)

    https://drive.google.com/file/d/0B8mzGh2PVjd-U1phNHRRQ3dySzg/view?usp=sharing

    Image data is copied to Clipboard and zone data is returned as an array.

    Wednesday, March 23, 2016 2:19 AM
    Answerer