ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Change jpeg image
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Alex

5 Posts

Posted - Apr 08 2014 :  13:16:37  Show Profile  Reply
How to properly adjust the contrast, brightness and color in the scanned image, and then save it in a jpeg file with the changes?

w2m

USA
1990 Posts

Posted - Apr 08 2014 :  15:14:25  Show Profile  Reply
Please remember to add which component you are using when posting questions or I may be wasting my time showing you something you do not need.
procedure TForm1.AdjustBrightnessContrastSaturation1Click(Sender: TObject);
{Adjust Brightness, Contrast, Saturation and SaveToFileJPG}
var
  iBrightness: integer;
  iContrast: integer;
  iSaturation: integer;
  iFilename: string;
begin
{ Brightness can assume values from -100 to 512.
  Contrast can assume values from -100 to 100.
  Saturation can assume values from 0 to 512. }
  iBrightness := 100;
  iContrast := -10;
  iSaturation := 0;
  { This method adjust brightness, contrast and color saturation in one step
    If a parameter is zero, it doesn't that parameter }
  ImageEnView1.Proc.AdjustBrightnessContrastSaturation(iBrightness, iContrast, iSaturation);
  { The quality factor for the current JPEG image. Range is 1 to 100, though
    typical range is 60 (low quality) to 95 (high quality).
    Higher values will improve image quality but require more disk space }
  ImageEnView1.IO.Params.JPEG_Quality := 95;
  ImageEnView1.IO.SaveToFileJpeg(iFilename);
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
Go to Top of Page

Alex

5 Posts

Posted - Apr 09 2014 :  09:03:01  Show Profile  Reply
Thanks for the help !

There are a few additional questions:
1. It is impossible to smoothly adjust these settings via TrackBar. I understand that change occurs with respect to the previous change, and not relative to the initial parameter values, or I have something wrong?
2. How can I restore the original values without reloading the image?
3. When the image is only obtained, all parameters are set to zero?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 09 2014 :  17:17:18  Show Profile  Reply
1a. The settings can be adjusted using a trackbar, but the best way is to operate on a small thumbnail that is visible to the user in a thread. Each time you run the thread you process a copy of the original thumbnail stored in a TIEBitmap in the thread.

Then when the user wishes to apply the changes visible in the thumbnail to the full image he selects an "Apply" button which is generally located adjacent to the thumbnail. The 'Apply" button runs the thread again on the full image which returns the same result only the processing uses the full image instead of the thumbnail. When processing the full image in the same thread it takes a little more time then when operating on the small thumbnail, but because the thread is only run one time on the full image the time is not noticeable because the application does not "hang" while the thread is running.

The threaded thumbnail approach is very speedy because the processing in done in its own thread and because the procedure uses a much smaller image than the full image.

This is not for the faint of heart or for developers with little threading knowledge; however, and sometimes takes some time even for a developer with moderate threading knowledge to get it correct.

If you attempt to write an image processing thread the best guidance I can give is get the image and the trackbar properties at the beginning of the thread from a Synchronized procedure. Then create a TImageEnProc in the thread and do the processing with the TimageEnProc runtime in the thread but not in a Synchronized procedure. Other than getting the image and the required parameter values from the main thread all the processing should be un Synchronized using the runtime TImageEnProc. After processing at the end of the thread, update the image visible to the user in another Synchronized procedure.

1b. To get the best results, save a copy of the original un-edited image to a TIEBitmap so the new trackbar values can be applied to the unchanged bitmap.

2. Restore the original image from a copy of the image held in a TIEBitmap.

3. I assume you mean by "When the image is obtained" you mean when a new image is loaded... You have to reset the trackbar values to their initial states yourself.

I hope this helps....

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: