Image processing library

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
 

Attachments

Last edited:

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:
 

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 (?)
 

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
Klaus
Switzerland
 

agraham

Expert
Licensed User
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
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.
 

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
Klaus
Switzerland
 

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?

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.

dennishea
 

LineCutter

Active Member
Licensed User
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.
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.
:sign0188:
 

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.
 

derez

Expert
Licensed User
Agraham - Saturation works from -100 for grayscale, 0 is unchanged, unlike the help.
 

TWELVE

Active Member
Licensed User
Andrew,

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:

B4X:
MyImage = "C:\Temp\test.jpg"
Image1.LoadPicture(MyImage) 
Image1.Visible= True
   DoEvents
    ' this initialises a couple of internal gamma lookup tables assuming gamma of 2.2
   ImageEdit.New1
   ' 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      
   ImageEdit.LoadImage(Image1.Image)
   'ImEd.UndoSave
   '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
   'ImEd.RotateLeft
   'ImEd.RotateRight
   'ImEd.Mirror
   'ImEd.Flip
   'ImEd.Crop(52,48,168,220)
   ImageEdit.resize(320,240)
   
   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,

TWELVE
 

agraham

Expert
Licensed User
Last edited:

TWELVE

Active Member
Licensed User
Hi Andrew,

thanks for your reply...

I have added the facility to the BitmapEx to dispose of the actual .NET bitmap while keeping the Basic4ppc BitmapEx object using BitmapEx.Release.
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,

TWELVE
 
Top