c++ decode CCITT encoded images in pdfs - c++

I'm trying to extract all images out of PDF files in C++. I'm stuck in decoding CCITT encoded images.
Does anyone know an opensourced code for this?
I use the ImageMagick Magick++ Library, is it possible to do the decoding with this library, too?
Thanks for your help!

CCITT is one of the encodings TIFF supports, though in a PDF file the CCITT images are probably raw data.
You can convert a raw CCITT image into a Tiff image using Fax2Tiff. It should be easy enough to work with the image once it is encoded as a Tiff.
Fax2Tiff is part of LibTiff. See LibTiff Source

Or you can append a header on it and treat it as a tiff file.

Related

Saving multi page tiff with jpeg compression

Is there any way to save multipage tiff with JPEG compression in C#? It seems EncoderValue enum does not have such a value. any free .net library available to achieve this?
Purpose is to reduce file size of color multipage tiff. Tried with LZW , but still size is not reduced much.all other compression types in enum make images b&w as well.

Read RGB triplets of JPEG files in C

to read bmp files we may use this http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx
as the header file and then get rgb triplets. How to get the rgb triplets of jpeg file, is there any such header file available. Please share the link if any.
The JPEG file format does not store the rgb triplets directly but it uses some sort of image compression. The file actually contains blocks of 64 (if I remember correctly) pixels which are attributed with a cosine pattern defining the actual colors.
You really should use a library (libjpeg, imagemagick, gd, ... e.g., depending on your use case) to read and decode the files and generate the rgb triplets in memory.
According to the answer to this question on MSDN, you could use the GDI+ component, which can load not only BMP, but JPG and other image formats too. From it, you will get a memory bitmap.
Here is an example on how to do that.
Check this library: libjpeg. This library implements JPEG image encoding, decoding,
and transcoding.

Saving frames in opencv without compression

I'm trying to use the imwrite() OpenCV function. I want to save the frames with the .TIFF extension. The problem that I have is that the saved images are compressed so I can't use them. Any idea how I can escape this compression?
thanks in advance
Do not mind what sietschie says. The TIFF flag is hardcoded in the opencv binaries with a LZW compression. You can just turn this off (comment it out) or change it.
In:
3rdparty/libtiff/tiff.h
Remove this line:
#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */
Then compile. Presto.
Tiff options other than that are automatically set (8 bit, 16bit, color, rgb, rgba,etc) depending on your image
According to the documentation OpenCV only exposes a limited set of options for writing image files.
Non of which belongs to TIFF-Files.
So unless you want to use your own function or modify the OpenCV source, this is not possible.
I would suggest using another uncompressed format for saving the frames like PXM or BMP, unless you have some specific reasons to use TIFF-Files.
cv::imwrite("imagen.TIFF", bayer, {cv::IMWRITE_TIFF_COMPRESSION, 1,
cv::IMWRITE_TIFF_XDPI, 72,cv::IMWRITE_TIFF_YDPI,72});
The simplest way is recompiling OpenCV or direct using libtiff, but I consider as not very good idea changing 3rdparty/libtiff/tiff.h: after this modification you can't save compressed TIFFs at all with OpenCV, and under non-windows systems you usually have separate libtiff (not as a part of OpenCV).
I suggest simpler approach (still OpenCV recompilation, but you save possibility of writing compressed tiff and don't change libtiff directly):
saving uncompressed TIFFs with OpenCV

c++ read image pixels

I want a c++ Code to read every pixel from an image file. and i want to save the pixels like:
r[]
g[]
b[]
does somebody know how to do this?
The answer depends on the format of the image file. Is it a format which contains raw RGB data (such as uncompressed TGA)? Is it a YUV image? Is it a compressed image such as JPEG or PNG?
There are already plenty of C++ libraries out there which can read a wide variety of image file formats, and then provide the pixel-level access you require. Take a look at Adobe's GIL, or CImg for example.
There are many freely available libraries for reading different image file formats. Since you're using C++ you might want to look at Adobe's Generic Image Library (GIL) or even OpenCV.
This will sort you out, very easy to use and 'low level' image library:
http://easybmp.sourceforge.net/
Two libraries that I've used that jump to mind are:
ImageMagick
libGD
These libraries can handle a wide variety of image formats, depending on what you need.

Is there any sample code to read thumbnail from Jpeg exif header?

I am writing application using c++, in windows.
I want to get a thumbnail from jpeg, without decoding the whole image.
How Can I read thumbnail from jpeg exif header?
Can any one offer me a some sample code?
Many thanks!
Unsurprisingly the library is called libexif has win32 port, and there is sample code for reading thubnail from file
Don't bother. You can create tumbnails very fast from JPEGs. They are compressed using DCTs on 8x8 pixel blocks. So, get the DC component (i.e. 0,0) of each block and you have an 1/64th thumbnail without decoding. Further scaling should be fast since there are hardly any pixels left.