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, November 14, 2007 11:50:30 PM(UTC)

loki  
loki

Groups: Registered
Posts: 5


Hi ,



When I load a page (Black & White scanned) from a PDF
with following method and ran ColorCommand it returns 2 colors








Dim rstImgTemp As RasterImage = _codecs.Load(fileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)
Dim cmdColorCount As New ColorCountCommand()
cmdColorCount.Run(rstImgTemp)




But when I load the same image with following overloaded method,








Dim info As CodecsImageInfo = _codecs.GetInformation(DocViewName.Trim, False, 1)
Dim imageRect As New Rectangle(0, 0, 150, 75)
imageRect =
RasterImageList.GetFixedAspectRatioImageRectangle(info.Width, info.Height, imageRect)

Dim rstImgTemp As RasterImage = _codecs.Load(DocViewName.Trim,
imageRect.Width, imageRect.Height, 24, RasterSizeFlags.Bicubic, info.Order, 1, 1)
Dim
cmdColorCount As New ColorCountCommand()
cmdColorCount.Run(rstImgTemp)


Is it normal?
If it is normal then, is it possible to find out whether a page is B&W or has more colors,
so that I can use different parameters to
load that page?




Thanks & Regards
Loki



 

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 : Thursday, November 15, 2007 12:56:42 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

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

Hello,

Do you mean that you don't get the correct number of colors when you load the image using the overloaded Codecs.Load method?

To get the correct number of colors, try to load the image as 1-bit using the codecs.Load method.

You can check the bits per pixel of the image before loading it by using the CodecsImageInfo Class. This class provides functionality for getting information about the image before loading it.
For more information, please read the following topic in the LEADTOOLS .Net documentation:
- CodecsImageInfo Class

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Thursday, November 15, 2007 4:33:33 AM(UTC)

loki  
loki

Groups: Registered
Posts: 5


Hi,
Thanks for the quick reply.

If I use info.bitsPerPixel I get a image with very poor quality.

My idea is to load thumb image by using

_codecs.Load(DocViewName.Trim, imageRect.Width, imageRect.Height, 24, RasterSizeFlags.Bicubic, info.Order, 1, 1)

With following options

_codecs.Options.Pdf.Load.DisplayDepth = 1
_codecs.Options.Pdf.Load.GraphicsAlpha = 1
_codecs.Options.Pdf.Load.TextAlpha = 1

And when user wants to view the page in full size,  

 

If the thumbnail image has more than 2 colors. then We can load that page with DisplayDepth = 24,   

If it contains Only 2 colors then we can load with  DisplayDepth = 1,   

 

So the problem here is
I am always getting more than 2 colors when i run colorCommand on the thumbimage( which is loaded with 24 bits perpixel).

It will be great if you can suggest me a way to find whether this page is B & W or Colored.
 
Thanks & Regards
Loki.

 
#4 Posted : Sunday, November 18, 2007 5:24:32 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

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

Hello,

For raster image formats such as BMP, GIF and TIFF, it is possible to know the pixel depth of the image without loading it, because the headers of these images contain that information.
However, PDF files are not pure raster images. They are documents that can contain images, text and shapes. That's why even if they only contain 2-color images; LEADTOOLS by default will load them as 24-bit images.

If you only want to determine if the image has 2 colors or multiple colors, one way is to load a small copy of the image by setting codecs.Options.Pdf.Load.XResolution and YResolution to small values before loading the image. You can then count the number of unique colors in the image using the ColorCountCommand Class.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
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-2020, Yet Another Forum.NET
This page was generated in 0.225 seconds.