[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 1234567[8]910 ]

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 06:49:08 06/08/01 Fri
Author: Michel
Subject: Re: Speed Issue in conversion from B/W to Grayscale
In reply to: Ann Weaver 's message, "Speed Issue in conversion from B/W to Grayscale" on 10:03:50 06/06/01 Wed

Hi Ann,

By default the ImageFormatTransform Dither and Quantize property are set True. Try turning both off, and each individual and compare the speed/quality. Since the origina is B/W, both False will probably be fine.


FormatTransform.Dither := False;
FormatTransform.Quantize := False;

Best regards,


>Good Morning Michel,
>Well, in further testing last night I have determined
>that it is definitely the conversion that is time
>consuming. It consistently takes 10 seconds on every
>scan. If I remark out the conversion code it is ready
>to save the image almost immediately (and will if
>changed to a .tif format instead of .jpg). If I leave
>the conversion code in and remark out the resize
>coding, the speed is again back to 10 seconds. Maybe
>there is something wrong with the way I am doing the
>I have included a sample of my coding below. I am
>using the Pegasus Tools TwainPRO and SmartScan Xpress
>Barcode packages as well to capture the image from the
>scanner and read the barcode. I am then using the
>Envision components to convert the image and elsewhere
>in the application to zoom, etc.
>I am performing the following on the PostScan event of
>the TwainPRO object.
>procedure TdmData.TwnPROPostScan(Sender: TObject;
>Cancel: WordBool);
> BarcodeNbr, DocumentName: String;
> DocumentNbr: Integer;
> ImageScrollBox: TImageScrollBox;
> FormatTransform: TImageFormatTransform;
> ResizeTransform: TResizeTransform;
> Screen.Cursor := crHourglass;
> { Copy scanned image to the clipboard & read the
>barcode }
> { Setup the filename based on the barcode detected }
> { Create a temp image }
> ImageScrollBox := TImageScrollBox.Create(Self);
> { Change to Grayscale image so it can be saved as a
> FormatTransform := TImageFormatTransform.Create;
> try
> FormatTransform.ImageFormat := ifGray256;
> FormatTransform.Apply(ImageScrollBox.Graphic);
> finally
> FormatTransform.Free;
> end;
> { Resize Image by 50% }
> ResizeTransform := TResizeTransform.Create;
> try
> ResizeTransform.Width :=
>Box.Graphic.Width)) * 0.5)));
> ResizeTransform.Height :=
>Box.Graphic.Height)) * 0.5)));
> ResizeTransform.Apply(ImageScrollBox.Graphic);
> finally
> ResizeTransform.Free;
> end;
> { Save the image }
> try
>ng + DocumentName);
> except
> { handle exceptions }
> end;
> { Release resources }
> ImageScrollBox.Free;
> { Add index to database }
> try
> with ADOtblImgIndex do
> begin
> Insert;
> ADOtblImgIndexFileName.AsString := DocumentName;
> ADOtblImgIndexScanDate.AsDateTime := Now;
> Post;
> end;
> except
> { handle exceptions }
> end;
> Inc(ImageCount);
> Screen.Cursor := crDefault;
>>Hi Ann,
>>I would assume the resize is the more time consuming.
>>The conversion should be fast even on large images.
>>For the resizing, are you using interpolation on the
>>TResizeTransform. I would try it without
>>interpolation, and the quality may still be very
>>Best regards,
>>>I have this all working now but is running fairly
>>>due to the conversion from B/W to Grayscale. I am
>>>scanning the images at B/W 300dpi which seems to be
>>>about the minimum I can go and still get a good read
>>>of the barcode contained in the image. However, due
>>>to the size of the image it makes the conversion from
>>>B/W to grayscale take about 10 seconds or so to
>>>convert (which is a necessity to store the image as
>>>.jpg). I then resize the image as I don't need/want
>>>store an image of that size. If I resize the image
>>>prior to the conversion it goes faster but I lost a
>>>lot of image quality that way. Conversion first, then
>>>resize works great but lacking speed.
>>>Does anyone have any suggestions on how to speed up
>>>this process?

[ Next Thread | Previous Thread | Next Message | Previous Message ]


[ Contact Forum Admin ]

Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.