Image processing library

Discussion in 'Additional Libraries' started by agraham, Jan 24, 2008.

  1. agraham

    agraham Expert Licensed User

    First stab at an image processing library as requested by LineCutter in the dzImage library thread. Does contrast, brightness, B&W and colour invert. Have a play.

    EDIT :- Version 1.2 including help file. Too much added to list here, have a look!

    EDIT :- Hasty update to version 1.3 including help file. I found a subtle bug (typo) when a filter function didn't behave as I expected. The example filters in the example are tidied up a bit too.

    EDIT : - Final(?) version 1.4 posted

    Attached Files:

    Last edited: Jan 27, 2008
  2. LineCutter

    LineCutter Active Member Licensed User

    I'd like to make a complaint ;) I can't keep up with the development of this library as it offers the options for more & more eye candy.

    Thanks again :sign0060:
  3. alfcen

    alfcen Well-Known Member Licensed User

    Hi agraham,

    You're a bloody legend :sign0188:

    Weather is bad enough to challenge gamma, brightness, contrast, etc.
    control with a slider. Your idea of using filter matrices for manipulation
    offers total freedom (and fun).

    Not familiar with the inner life of a dll. Could yours and dzt's dzImage be
    merged into the most powerful library the compact .NET world has ever seen?

    I faintly recall that you are using VS while dzt is in to #Develop (?)
  4. klaus

    klaus Expert Licensed User

    Hi agraham, dzt and Erel
    I aggree with alfcen and would even dream of a merge of agraham's, dzt's libraries (including agraham's FloodFillLib) with the ImageLib and the Form drawing functions to have all the image processing and drawing functions in THE ImageLib or whatever name. I am sure that this would make programming easier for the alpha programmers like me and a lot of others.

    I don't remember who said:
    'Human beeing is working like crazy to have less to do'
    Unfortunately the 'hard work' is for you and the less to do for us others.

    Thanks in advand to have a thought on this, dreams become sometimes reality.

    Best regards
  5. agraham

    agraham Expert Licensed User

    I'm not sure that this is necessarily a good idea. ImageLib, FloodFill and dzImage are really drawing libraries. ImageEdit is really for photo manipulation. I feel that these are two quite distinct activities. The drawing libraries work internally directly with 8 bit unsigned gamma corrected colour values, my ImageEdit works internally with 15 bit signed linear colour values - conceptually the two don't really mix.

    I'll be adding a few more things appropriate to photo work - Undo, Crop, Rotate and possibly Resize. I might possibly add some colour/hue manipulation but I need to experiment with how to present that. Any other suggestions welcome.
  6. klaus

    klaus Expert Licensed User

    Hi agraham,
    I understand that from the pricilple point of view it is not reasonable to merge ImageEdit with the other libraries, but at least the 3 drawing libraries ImageLib, FloodFill and dzImage could be merged together.

    Best regards
  7. Erel

    Erel Administrator Staff Member Licensed User

    Probably in the next version most libraries will be compiled during the compilation and into the executable file.
  8. dennishea

    dennishea Active Member Licensed User

    Erel am I correct in thinking that then the whole library woundn't need to then be bundled with the executeable in the cab file therefore make a smaller foot print on the consumers system?

  9. Erel

    Erel Administrator Staff Member Licensed User

    Most libraries will be embedded in the executable file.
    The overall size will be similar as the executable file will be larger.
  10. dennishea

    dennishea Active Member Licensed User

    Erel, does the whole dll get compiled with the exeacuteable or just the parts of the dll that get used? I hope these questions don't seem to dumb, just trying to understand better how everything works together.

  11. agraham

    agraham Expert Licensed User

    This thread is going :sign0006:
  12. dennishea

    dennishea Active Member Licensed User

    Sorry Agraham, my apologze.:signOops::sign0188:
  13. LineCutter

    LineCutter Active Member Licensed User

    I'd just like to say again how impressed I am by the help & support that this programming language & forum creates. It seems that there's nothing that can't be done, as long as you ask about it here.
  14. agraham

    agraham Expert Licensed User

    OK - probably the final iteration of this library, complete with updated help, posted on the first post. I've really enjoyed doing this one as I have been interested in the technicalities of colour reproduction on TV, computers and printers for years but have never found a need to code anything myself. Once the basic data handling is in place it is atonishing the speed at which you can add functionality.

    Resize, Crop, Flip, Mirror and Rotates added. ToBandW renamed GrayScale. All the GetImage methods rolled into one. SaveImage can save individual colour channels. Saturation and Hue adjustment added and Undo implemented.
  15. derez

    derez Expert Licensed User

    Agraham - Saturation works from -100 for grayscale, 0 is unchanged, unlike the help.
  16. agraham

    agraham Expert Licensed User

    Sorry, the comment about saturation in the demo is correct but the help, as you say, is incorrect.
  17. TWELVE

    TWELVE Active Member Licensed User


    i tested a bit with your ImageEdit Lib and ran into an issue when i tried to save the edited image into the original file:

    MyImage = "C:\Temp\test.jpg"
    ' this initialises a couple of internal gamma lookup tables assuming gamma of 2.2
    ' load the image into internal buffers and linarise it to signed 15 bit colour values
       ' this takes out the gamma correction and allows for a measure of underflow recovery.
       ' doing processing on gamma corrected images can cause unwanted colour shifts   
       ' doing processing on 8bit values can cause colour banding and blocking due to lost resolution
       ' ImEd.SetIpGamma(1.8) ' default after New1 is 2.2
       ' ImEd.SetOpGamma(1.89) ' default after New1 is 2.2      
       'ImEd.Brightness(-20) ' adjust brightness from -100% to 100%, 0 is unchanged
       'ImEd.Brightness(20) ' because we are signed internally this brings the image back from underflow
       'ImEd.Contrast(120) ' adjust contrast from -100% to x00% where 100% is unchanged
       'ImEd.Saturation(-50) ' adjust saturation as a percentage  -100 is gray 0 is unchanged +110 is 10% increase
       'ImEd.Hue(90,110,110)' adjust hue by altering each colour Hue(R, G, B) by the given percentage
       'ImEd.GrayScale ' make the image grayscale - note it is still a 3 colour image
       'ImEd.InvertImage ' invert the colour values of the image
       Image1.Image = ImageEdit.GetImage(
    "c"' R, G, B for colour channels, L for luminance, full colour for anything else
       ImageEdit.SaveImage(MyImage,"J"' J - jpg, B - bmp, G - gif, P - png, anything else  - jpg
    The programs throws an exception at the "ImageEdit.SaveImage(MyImage,"J") ' J - jpg, B - bmp, G - gif, P - png, anything else - jpg" line, it is in german though, saying something like "general GDI+ error".

    If i use a different file for the ImageEdit.SaveImage, then everything works fine.I suspect, that the image file is still opened somehow by the "Image1.LoadPicture(MyImage)" , but did not find how to close it or if there's something like a close needed ever.

    kind regards,

  18. agraham

    agraham Expert Licensed User

    I can't do anything about that, it's a .NET Bitmap object feature. See

    EDIT :- Note that since that post was made I have added the facility to the BitmapEx to dispose of the actual .NET bitmap while keeping the Basic4ppc BitmapEx object using BitmapEx.Release.
    Last edited: Jul 11, 2010
  19. TWELVE

    TWELVE Active Member Licensed User

    Hi Andrew,

    thanks for your reply...

    Can you give me( may i have...for the british people :)) ) a hint in what lib the BitmapEx object is located...? Can you maybe even give a code snippet...?

    kind regards,

  20. agraham

    agraham Expert Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice