Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, September 26, 2007 1:16:32 AM(UTC)
wvanoeveren

Groups: Registered
Posts: 4


Hello,

I'm developping a tool which needs to convert a color image (tiff - already converted from html using another toolkit) to a black and white document (multipage tiff, with the original document clipped into A4-size pages). I found 2 methods of doing the stuff needed, but eventually the complete conversion takes about 40 seconds which is too long for the purpose of the program. Included you can find an example color-tiff which needs to have the conversion... (http://download.yousendit.com/5B6486A271D2836F)
Used platform:
- Visual Studio 2005 (vb.net)
- Leadtools v15

Can somebody please help me on this one ?

Thanks in advance,

Wim Vanoeveren
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, September 26, 2007 10:56:14 AM(UTC)

jigar  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Hello,

I tried it with LZW compresssion and it takes about 50 seconds here for a 8 bit image.  First I was doing it with jpeg compression which took 3 seconds.  Then I tried just regular Tif compression and it only takes 6 seconds for a 4 bit image.  I don't think you will be able to save it back with LZW compression.  Tif compression is a standard so any TIFF reader will be able to read it.
File Attachment(s):
BgrToGrayCode.txt (3kb) downloaded 24 time(s).
 
#3 Posted : Thursday, September 27, 2007 1:01:54 AM(UTC)
wvanoeveren

Groups: Registered
Posts: 4


I have tested your code in vb.net but i found out that it still takes 43 seconds to convert a color tiff (LZW) to a B/W tiff (CCITTG4), with the inclusion of the split into 6 single pages which are then added to 1 multipage tiff. I use the CropCommand tool in combination with a rectangle to fetch the necessary piece (A4 format -- default height = 3508). Can you please give me some more advice on how i can completely do this run under 10 seconds ? Currently we are using the Peernet driver which can do this same job in 6-8 seconds, but it can only be run from an application and not from within a service ...

Below you can find the code which i use to do the split ...

Dim myNewRasterImage As RasterImage = codecs.Load(outputFile)
Dim myOriRasterImage As RasterImage = myNewRasterImage.CloneAll
heightOriginalDoc = myNewRasterImage.ImageHeight
currWidth = myNewRasterImage.ImageWidth
currYPos = 0
currPageNr = 1
currHeight = defaultHeight
Do While Not (heightOriginalDoc <= defaultHeight)
rc = New Rectangle(currXPos, currYPos, currWidth, currHeight)
currYPos = currYPos + currHeight
CropCommand.Rectangle = rc
CropCommand.Run(myNewRasterImage)
codecs.Save(myNewRasterImage, outputMultipage, RasterImageFormat.CcittGroup4, 1, 1, 1, 1, CodecsSavePageMode.Append)
heightOriginalDoc = heightOriginalDoc - currHeight
If heightOriginalDoc <= defaultHeight Then
rc = New Rectangle(currXPos, currYPos, currWidth, heightOriginalDoc)
CropCommand.Rectangle = rc
CropCommand.Run(myOriRasterImage)
Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, defaultWidth, defaultHeight, myOriRasterImage.BitsPerPixel, myOriRasterImage.Order, myOriRasterImage.ViewPerspective, myOriRasterImage.GetPalette(), IntPtr.Zero, 0)
Dim myCombineCommand As CombineFastCommand = New CombineFastCommand
myCombineCommand.DestinationRectangle = New Rectangle(0, 100, destImage.ImageWidth, destImage.ImageHeight)
myCombineCommand.SourcePoint = Point.Empty
myCombineCommand.DestinationImage = destImage
myCombineCommand.Flags = CombineFastCommandFlags.OperationAdd Or CombineFastCommandFlags.Destination0
myCombineCommand.Run(myOriRasterImage)
codecs.Save(destImage, outputMultipage, RasterImageFormat.CcittGroup4, 1, 1, 1, 1, CodecsSavePageMode.Append)
destImage.Dispose()
currPageNr = currPageNr + 1
Exit Do
End If
currPageNr = currPageNr + 1
myNewRasterImage = myOriRasterImage.CloneAll
Loop


Thanks in advance,

Wim
 
#4 Posted : Thursday, September 27, 2007 6:42:24 AM(UTC)

jigar  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Thanks for the code.  I will test it out and try a few other things I can think of.  I may need to contact one of the engineers, so my reply maybe a little slow.
 
#5 Posted : Sunday, September 30, 2007 10:36:35 PM(UTC)
wvanoeveren

Groups: Registered
Posts: 4


Big thanks already !! let's hope you (or one of the engineers) can find a solution !
 
#6 Posted : Tuesday, October 2, 2007 12:14:57 PM(UTC)

jigar  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Hello,

With your code I did lots of tests, and I wasn't able to get any high times for the conversion.  All the test runs resulted in times between 8-15 seconds.  To make sure it wasn't the cache that was speeding it up, I cold booted my computer with normal background services running and I got 10 seconds from the start of your code to the end.  I rebooted my PC three times and all were 9-10 secs.  The next runs were all ~8 seconds, probably because of caching.  There were a couple times it was around 15 seconds, but that was with some harddrive activity on the side.  I tried testing the program under >80% memory usage, and I got 35 seconds for that (I had about 10 VS2005 projects open and some other programs, total mem usage was 927mb).  My system is 3.0Ghz with 1GB RAM.  What are your system specs?  I would say 10 seconds is pretty good for such a large image.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.127 seconds.