locked
my point of view is needed at this moment !! for my forum post : would like the processing time for this program to be faster, how? do you have any suggestions? RRS feed

  • Question

  • my point of view is needed at this moment !!

    the reason why I try to increase the processing speed of my program: RNN417 is that I am trying to build a full  program more elaborate, which will have the task to analyze an image by breaking it down into 10 different Zones density .

    Zone 0 = 0,0,0 pixels to 25,25,25
    Zone I = 25,25,25 pixels to 50,50, 50
    Zone II = 50,50,50 to 75,75,75
    and so on up to

    Zone X = 225,225,225, to 255,255,255

    My idea is based on my knowledge of the Zones System of Ansel Adams , which i had learned

    in a school of photography, many years ago !!!!

    see wikipedia

    https://en.Wikipedia.org/wiki/Zone_System

    The Zone System is a photographic technique for determining optimal film exposure and development, formulated by Ansel Adams and Fred Archer.<sup class="reference" id="cite_ref-1">[1]</sup> Adams described the Zone System as "[...] not an invention of mine; it is a codification of the principles of sensitometry, worked out by Fred Archer and myself at the Art Center School in Los Angeles, around 1939-40.

    Using essentially in landscape photography, it helps to determine the best exposure by taking several readings with a photometers and place them in the Zone scale in order to in determining the final exposure, Aperture F / and speed.

    To analyze our final silver negative, we were using a densitometer.

    Now I try to transpose the densitometer stage of the analysis in digital photo.
    My program will therefore scan an entire image, Zone by Zone will color the 10 areas in different colours in order to visualize our final photo, to determine if our picture is under or over exposed

    therefore demand will be heavy, and the speed and the construction of the program will be crucial to make a viable version! say 1 to 5 minutes processing time will be very acceptable according to my point of view.

    Therefore remained on the air, my super-version simulation areas System is coming!

    ref: my post : https://social.msdn.microsoft.com/Forums/en-US/66f8d15e-e750-4646-afe0-b9542bfe4761/i-would-like-the-processing-time-for-this-program-to-be-faster-how-do-you-have-any-suggestions?forum=smallbasic

    Yvan Leduc

    Wednesday, March 16, 2016 9:08 PM
    Answerer

Answers

  • I would try:

    LDImage.SplitImage - to split an image into say 100 sub images, say 10 by 10

    LDImage.Statistics - to get exposure statistics for each sub image - min, max, mean and STDev for R,B,G

    LDImage.Histogram - to get a histogram of R,G,B intensities to plot with LDGraph to see the distribution

    The new LDImage methods I mentioned your ealier post for fast pixel by pixel manipulation (at least *5 faster than using LDImageGetPixels) using a working image method for additional stats like the zones you describe if you want this.

    Other LDImage methods can then be used to correct under/over exposure if you want to go that way.

    Wednesday, March 16, 2016 9:52 PM
  • I don't have many samples apart from those I got from web, e.g. sepia.  The link is the best place to start.

    http://msdn.microsoft.com/en-us/library/a7xw19wh%28v=vs.110%29.aspx

    The code I use is this so it may help to explain - basically it adds and multiply RBG components.

    c = dImg.GetPixel(i, j);
    R = range(c.R * data[0, 0] + c.G * data[1, 0] + c.B * data[2, 0] + c.A * data[3, 0] + 255 * data[4, 0] * data[4, 4]);
    G = range(c.R * data[0, 1] + c.G * data[1, 1] + c.B * data[2, 1] + c.A * data[3, 1] + 255 * data[4, 1] * data[4, 4]);
    B = range(c.R * data[0, 2] + c.G * data[1, 2] + c.B * data[2, 2] + c.A * data[3, 2] + 255 * data[4, 2] * data[4, 4]);
    A = range(c.R * data[0, 3] + c.G * data[1, 3] + c.B * data[2, 3] + c.A * data[3, 3] + 255 * data[4, 3] * data[4, 4]);
    dImg.SetPixel(i, j, System.Drawing.Color.FromArgb(A, R, G, B));
    

    Thursday, March 17, 2016 6:36 PM
  •  Below is  LDimage.SplitImage    Ldimage.ColorMatrix  sample.

    Url_Photo()
    Crop_ColorChange()

    Sub Crop_ColorChange
      m=4
      n=4
      Crop_Photo= LDImage.SplitImage(PX,m,n)
      For i=1 To m            '  X 
        For j=1 To n           '  Y 
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
      PGEND= Shapes.AddText(" Photo is cropped  ")
      Shapes.Zoom(PGEND,2,2)
      Shapes.Animate(PGend,IW/2,IH/10,1000)
      Program.Delay(2000)
      For i=1 To m            '  X 
        For j=1 To n           '  Y 
          matrix[1] = "1=0.393;2=0.349;3=0.272;4=0;5=0"     '  you can change matrix value
          matrix[2] = "1=0.769;2=0.686;3=0.534;4=0;5=0"
          matrix[3] = "1=0.189;2=0.168;3=0.131;4=0;5=0"
          matrix[4] = "1=0;2=0;3=0;4=1;5=0"
          matrix[5] = "1=0;2=0;3=0;4=0;5=1"
          Shapes.Remove( sCrop[i][j])  
          LDImage.ColorMatrix(Crop_Photo[i][j],matrix)
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
    EndSub

    Sub Url_Photo
      url="http://farm3.static.flickr.com/2674/3748308428_a6a082153f.jpg"
      PX=ImageList.LoadImage(url)
      IH=ImageList.GetHeightOfImage(PX)
      IW=ImageList.GetWidthOfImage(PX)
      GraphicsWindow.Width=IW+20
      GraphicsWindow.Height=IH+20
    Endsub

    Gray scale & Block effect

    Url_Photo()
    Crop_ColorChange()

    Sub Crop_ColorChange
      m=10
      n=10
      Crop_Photo= LDImage.SplitImage(PX,m,n)
      For i=1 To m            '  X 
        For j=1 To n           '  Y 
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
      PGEND= Shapes.AddText(" Photo is cropped  ")
      Shapes.Zoom(PGEND,2,2)
      Shapes.Animate(PGend,IW/2,IH/10,1000)
      Program.Delay(2000)
      '  gray scale ......  r = 0.298912    g = 0.586611  b = 0.114478
      For i=1 To m             '  X 
        For j=1 To n           '  Y 
          LDImage.EffectBlocks( Crop_Photo[i][j],15)
          matrix[1] = "1=0.299;2=0.299;3=0.299;4=0;5=0"
          matrix[2] = "1=0.587;2=0.587;3=0.587;4=0;5=0"
          matrix[3] = "1=0.114;2=0.114;3=0.114;4=0;5=0"
          matrix[4] = "1=0;2=0;3=0;4=1;5=0"
          matrix[5] = "1=0;2=0;3=0;4=0;5=1"
          Shapes.Remove( sCrop[i][j])  
          LDImage.ColorMatrix(Crop_Photo[i][j],matrix)
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
    EndSub

    Sub Url_Photo
      url="http://farm3.static.flickr.com/2674/3748308428_a6a082153f.jpg"
      PX=ImageList.LoadImage(url)
      IH=ImageList.GetHeightOfImage(PX)
      IW=ImageList.GetWidthOfImage(PX)
      GraphicsWindow.Width=IW+20
      GraphicsWindow.Height=IH+20
    Endsub

    Thursday, March 17, 2016 11:54 PM
    Answerer

All replies

  • I would try:

    LDImage.SplitImage - to split an image into say 100 sub images, say 10 by 10

    LDImage.Statistics - to get exposure statistics for each sub image - min, max, mean and STDev for R,B,G

    LDImage.Histogram - to get a histogram of R,G,B intensities to plot with LDGraph to see the distribution

    The new LDImage methods I mentioned your ealier post for fast pixel by pixel manipulation (at least *5 faster than using LDImageGetPixels) using a working image method for additional stats like the zones you describe if you want this.

    Other LDImage methods can then be used to correct under/over exposure if you want to go that way.

    Wednesday, March 16, 2016 9:52 PM
  • Hi LitDev !

    thanks for your helps and suggestions. !!

    all your methods are good, i don't know which one to choose !!!!

    I think I will write my program the way i visualize the final result , and then insert in, the best methods for my purposes, and speed improvement.

    My Nikon camera give me a histogram for each picture, and give me flashing warning if highlights are overexposed , so why building this program ? for fun, just for fun, and for simply growth my knowledge in basic programming.

    it's a mind challenge, a mind exercise , and it's fun to compute !!!

    have you  a sample code example for:

    How to use Ldimage.ColorMatrix , i like this command !!    but i don't understand it to much,

    and i like also your suggestions to use  LDimage.SplitImage 

    With the Zone System technique in photography you can accomplish spectacular photography, most in black and white .

    I have already visited an exhibition of the best pictures of Ansel Adams, and these giant enlargements of 18 x 24 black and white are of incredible beauty. !!
    He used a camera large format 8 x 10 inch, which would be around 500 megapixel camera as a camera.

    take a look:    http://www.anseladams.com/

    Greetings !

    Thursday, March 17, 2016 4:10 PM
    Answerer
  • I don't have many samples apart from those I got from web, e.g. sepia.  The link is the best place to start.

    http://msdn.microsoft.com/en-us/library/a7xw19wh%28v=vs.110%29.aspx

    The code I use is this so it may help to explain - basically it adds and multiply RBG components.

    c = dImg.GetPixel(i, j);
    R = range(c.R * data[0, 0] + c.G * data[1, 0] + c.B * data[2, 0] + c.A * data[3, 0] + 255 * data[4, 0] * data[4, 4]);
    G = range(c.R * data[0, 1] + c.G * data[1, 1] + c.B * data[2, 1] + c.A * data[3, 1] + 255 * data[4, 1] * data[4, 4]);
    B = range(c.R * data[0, 2] + c.G * data[1, 2] + c.B * data[2, 2] + c.A * data[3, 2] + 255 * data[4, 2] * data[4, 4]);
    A = range(c.R * data[0, 3] + c.G * data[1, 3] + c.B * data[2, 3] + c.A * data[3, 3] + 255 * data[4, 3] * data[4, 4]);
    dImg.SetPixel(i, j, System.Drawing.Color.FromArgb(A, R, G, B));
    

    Thursday, March 17, 2016 6:36 PM
  •  Below is  LDimage.SplitImage    Ldimage.ColorMatrix  sample.

    Url_Photo()
    Crop_ColorChange()

    Sub Crop_ColorChange
      m=4
      n=4
      Crop_Photo= LDImage.SplitImage(PX,m,n)
      For i=1 To m            '  X 
        For j=1 To n           '  Y 
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
      PGEND= Shapes.AddText(" Photo is cropped  ")
      Shapes.Zoom(PGEND,2,2)
      Shapes.Animate(PGend,IW/2,IH/10,1000)
      Program.Delay(2000)
      For i=1 To m            '  X 
        For j=1 To n           '  Y 
          matrix[1] = "1=0.393;2=0.349;3=0.272;4=0;5=0"     '  you can change matrix value
          matrix[2] = "1=0.769;2=0.686;3=0.534;4=0;5=0"
          matrix[3] = "1=0.189;2=0.168;3=0.131;4=0;5=0"
          matrix[4] = "1=0;2=0;3=0;4=1;5=0"
          matrix[5] = "1=0;2=0;3=0;4=0;5=1"
          Shapes.Remove( sCrop[i][j])  
          LDImage.ColorMatrix(Crop_Photo[i][j],matrix)
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
    EndSub

    Sub Url_Photo
      url="http://farm3.static.flickr.com/2674/3748308428_a6a082153f.jpg"
      PX=ImageList.LoadImage(url)
      IH=ImageList.GetHeightOfImage(PX)
      IW=ImageList.GetWidthOfImage(PX)
      GraphicsWindow.Width=IW+20
      GraphicsWindow.Height=IH+20
    Endsub

    Gray scale & Block effect

    Url_Photo()
    Crop_ColorChange()

    Sub Crop_ColorChange
      m=10
      n=10
      Crop_Photo= LDImage.SplitImage(PX,m,n)
      For i=1 To m            '  X 
        For j=1 To n           '  Y 
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
      PGEND= Shapes.AddText(" Photo is cropped  ")
      Shapes.Zoom(PGEND,2,2)
      Shapes.Animate(PGend,IW/2,IH/10,1000)
      Program.Delay(2000)
      '  gray scale ......  r = 0.298912    g = 0.586611  b = 0.114478
      For i=1 To m             '  X 
        For j=1 To n           '  Y 
          LDImage.EffectBlocks( Crop_Photo[i][j],15)
          matrix[1] = "1=0.299;2=0.299;3=0.299;4=0;5=0"
          matrix[2] = "1=0.587;2=0.587;3=0.587;4=0;5=0"
          matrix[3] = "1=0.114;2=0.114;3=0.114;4=0;5=0"
          matrix[4] = "1=0;2=0;3=0;4=1;5=0"
          matrix[5] = "1=0;2=0;3=0;4=0;5=1"
          Shapes.Remove( sCrop[i][j])  
          LDImage.ColorMatrix(Crop_Photo[i][j],matrix)
          sCrop[i][j]= Shapes.AddImage(Crop_Photo[i][j])
          Shapes.animate(sCrop[i][j],iw/m*(i-1),ih/n*(j-1),2000)
        EndFor
      EndFor
    EndSub

    Sub Url_Photo
      url="http://farm3.static.flickr.com/2674/3748308428_a6a082153f.jpg"
      PX=ImageList.LoadImage(url)
      IH=ImageList.GetHeightOfImage(PX)
      IW=ImageList.GetWidthOfImage(PX)
      GraphicsWindow.Width=IW+20
      GraphicsWindow.Height=IH+20
    Endsub

    Thursday, March 17, 2016 11:54 PM
    Answerer
  • Thanks ! NaochanON

    i tried , it's good, very good samples !! i'll keep it in my archives.

    i will study it, i have to learn how it works, and when i will master those news instructions

    like LDImage.SplitImage, LDImage.ColorMatrix, and then i will incorporate to improve my programs !

    at the moment I'm not quite comfortable with these new instructions, for using well, and above all to understand them and control them.

    Friday, March 18, 2016 4:10 PM
    Answerer