Saving multi page tiff with jpeg compression - 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.

Related

can we create gif image without lzw compression?

I want to create a gif image from scratch using hex codes. I do not want to use LZW compression on the image data I produce. Is it possible to create a gif without LZW compression on image data so that all image viewing softwares can read it?
No. There is no uncompressed option in the GIF format. The image data is always compressed with LZW.

Compression of a single RGB image ( with c++ )

I am currently streaming my OpenGL rendered images through a websocket. I use the ZLib compression to compress the RGB data on the server side. On the client side I simply decompress and show the images.
My compression steps :
S3TC Texture compression from OpenGL
ZLib compression of step 1 with Qt framework
How can I compress even further? Is MPEG-4 encoding of a simple image an option or even possible? How can I reduce the image size even further?
S3TC is lossy, so if you want more compression, use another lossy approach, like JPEG, and crank up the compression until you don't like the result. Then back off.
If images are similar to each other, use some standard one-pass video compression algorithm. If images are distinct, why wouldn't you just use JPEG or some other (more modern) image compression algorithm? In either case it should be quite easy to find suitable libraries for server and client side, no need to invent and develop your own codecs and formats.

Serialize OpenCv Mat using JSON in C++

I'm trying to write a TCP client/server application that transmits objects containing OpenCv Mat. I'd like to serialize these objects using JSON. I found some libraries that help me in doing that (rapidjson), but they of course do not take into account images as object members.
What would you suggest to serialize in a JSON object a cv::Mat variable? How can I use RapidJson, for example, to achieve that?
imencode can be used to encode an viewable image (with CV_8UC1 or CV_8UC3 pixel formats) into a std::vector<uchar>. Link to documentation.
The vector<uchar> will contain the same bytes as if OpenCV had saved the image into one of the supported image file formats (such as JPEG or PNG) and then have the file bytes loaded back into a byte array.
imencode can be found in highgui module when using OpenCV 2.x, or imgcodecs module when using OpenCV 3.x.
With the compressed data in a vector<uchar>, you can use Base64 encoding to format it into a string, which can then be added as a JSON value inside a JSON object.
When using JSON to transmit large amounts of data, consider very very carefully the character encoding format that the JSON library is instructed to emit. Normally, If a large portion of the data is going to be Base64, you will want to make sure the JSON is emitted in UTF8.
If you have the option of sending in binary (which requires an "out-of-band" design in the web service, something not always doable), it should be seriously considered.
When considering different serialization choices for images, these things should be taken into account:
Typical image sizes (total number of pixels)
Size efficiency is less of a concern if images are small.
Pixel format (number of channels and precision)
Most common image file formats will only allow 8-bit grayscale and 24-bit RGB pixel data. Trying to save higher-precision pixel data into these image formats will result in partial loss of precision.
Available transmission bandwidth (if it is scarce enough to be a concern). With less available bandwidth, compression becomes more important.
Compression options.
Typical (photographic or synthetic) images are highly compressible due to the common sense that images that are too "dense" will be too hard to comprehend when viewed by human eyes.
Compression can be lossless or lossy.
Choice of compression may depend on the statistical characteristics of the pixel values (image content).
As mentioned above, if compression is performed by encoding into some image formats, you have to make sure the image format can satisfy the pixel value precision requirements of your application.
If no existing image format meets your requirements and you still want to perform lossless compression, consider using the zlib API that is integrated into the OpenCV Core module.
If you are good at image processing and data compression theory, you may be able to devise an application-specific compression method based on your own needs.
Remember that reducing the image resolution can be a powerful (and super-lossy) way of reducing the transmission file size. Consider carefully what minimum image resolution is actually needed for your application.
Other considerations
Binary or text
Endianness
Availability of highgui, imgcodecs or an image decoder for the chosen image format on the receiving end.
Information source: just did this a few months ago.

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.

c++ decode CCITT encoded images in pdfs

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.