Tesseract - train with different image format than used for primary OCR - tesseract

As discussed on this SO Question, tesseract often operates better with .png files than with .tiff files. (I have also experienced this directly myself). Unfortunately, there are fewer box editors available that can handle .png files. I therefore am tempted to train my data using .tiff files but then use .png files for my main OCR work. Will doing so reduce the effectiveness of the training? If so, are there any ways to address it (other than just finding a box editor that can accept .png files)?

Some editors such as jTessBoxEditor (Tesseract AddOns page) support both TIFF and PNG formats. Since TIFF can be multi-page image, it can have a lot more samples for your character set than single-page PNG.
https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract

Related

Generating smaller video file size from frames

I am doing a project in which I have a video I divide the video into frames and then the image steganography is applied to the frames and the encoded frames are generated. Then the encoded frames are to be converted into video again. All of the methods are applied successfully but the only problem is that I get the encoded video which is very large then the original video. I am using the movie2avi function to generate the video.
Can someone suggest any way to generate the video which is not very large compared to the original video?
First, if you're using movie2avi, you have a limited choice of very poor codecs (compression formats). If you have a new enough version of Matlab (R2009b+ I think) you should be using the VideoWriter class instead. The choice of codecs is still not very good, but they are of much better quality. You didn't indicate which codec (or OS) you're using so I can't recommend an alternative.
Second, even under ideal circumstances you should expect your movie file to get larger with what you're doing unless you apply additional compression. Adding steganographic content is akin to adding noise so you're making the data harder to compress. In both movie2avi and VideoWriter you can adjust the compression level or quality depending on the codec. Also, the default movie2avi codec under Linux and OS X uses no compression so the file will be huge if you haven't changed that.
If VideoWriter doesn't meet your needs (or if your version doesn't have it) you can try my QTWriter class on GitHub that allows one to export QuickTime movies in Matlab. It works very much like VideoWriter, but allows you to create high quality QuickTime movies using a few image-based codecs. No inter-frame compression is used and the PNG and TIFF formats are lossless (this may be important to your steganographic application) while being very efficient at encoding content like that often generated in Matlab. There is also a JPEG format that may be better suited to general images. The QuickTime files can then be converted to other formats if needed. You can read more and see examples here and download the single M-file here.
This is completely dependent on what you are trying to hide in the original video. Remember that the original video is using a compression codec that can take advantage of minimal change frame to frame and various other things, but if you go and try to hide something in that video through steganography, you are making it more difficult for the compression algorithm to do that, which will definitely result in a larger file. So you have to be careful what you are attempting to do, and how you are attempting to encode it.

How does Adobe Fireworks store vector information, pages, and layers in PNG format?

How is fireworks able to store this extra information in a format that is otherwise flat raster. And is there any open source way to write similar vector, layered, paginated files in Png format that would be readable by fireworks?
The PNG format allows for ancillary data chunks to store metadata aside from the image itself. I don't believe anyone's actually worked out the format that Adobe stores that data in though.

Matlab access PDF as an array of images

Building a system which search for a specific region in the picture, and saves it. Everything works fine. Mostly I am going to extract these regions from pdf books.
So I am looking for a solution to treat PDF file in matlab as an array of images (each page is an image). Up till now the only thing I have found is how to open pdf files in matlab.
The best solution I came up with is to export PDF as many PNG images and iterate through them. There is nothing bad with these idea, but I am wondering am I missing something
Judging from this page it appears to be impossible to import pdf directly into matlab:
And a quick file exchange search for 'pdf import' only offers an attempt to extract text, rather than the images.
So all in all your approach of saving the pdf as images and then importing them seems to be the way to go.
I agree with Salvador Dali and Dennis. To convert each page of the PDF to a png image, I downloaded imagemagick and followed the commands here:
https://aleksandarjakovljevic.com/convert-pdf-images-using-imagemagick/
Specifically:
convert -density 150 -antialias "input_file_name.pdf" -resize 1024x -quality 100 "output_file_name-%03d.png"
Of course, there are other discussion about using ImageMagick for this purpose:
Converting a PDF to PNG and
Convert PDF to PNG using ImageMagick
This is an old thread, but it's the one I found when I asked the same question, so I thought I would elaborate in case it's helpful to future users who also land on this thread.

MATLAB <---> Image editor with support for layers

I was wondering if anybody knows of an API, toolbox, or library that extracts layers from an image format that is supported by a free editor such as Paint.NET (native format: .pdn)
Motivation: An interface to an image with layers that can be edited in a free image editor would be of interest for those of us who do computer vision and machine learning in MATLAB. For example, it could facilitate the automatic collection of manual pixel annotations for supervised learning.
I suggest using the .PSD Photoshop file format, which has layers support and is also implemented by many non-Adobe applications.
The PSD plugin for Paint.NET allows you to open and save PSD images: http://www.psdplugin.com/
You can then use Imagemagick to extract the layers to a format that MATLAB can read:
convert filename.psd filename-%d.png
Almost nothing can read a .pdn file. http://extension.nirsoft.net/pdn
So, you are left with the following options.
Use GIMP to read in the file, and export it into something matlab supports: http://www.mathworks.com/help/techdoc/ref/imread.html.
Use GIMP to read in the file, and export it into something ImageMagick supports:http://www.imagemagick.org/script/formats.php and then convert it into something matlab supports.
Export the data from Paint.NET into a matlab friendly format.
Note, the Matlab links are for the image processing toolbox, if you don't have that, the options are more limited.

How to create a PNG image that is only a byte

We've seen PNG images on the web that are less than 1kb. When I create a new blank PNG in Photoshop, its size is about 20-30 Kb :(
For example, I've seen a 100*10 px PNG that was only 90 bytes!
Which Apps can generate these? Do you have any tips?
After fvu's answer: plz tell me what optimizer is better than other?
There no reason a minimal png should be that big. Check out png optimizers like this one or this online tool should Photoshop not include such a tool. Google knows about even more PNG optimizer tools.
Edit: a 10*100px png floodfilled with red measures 143 bytes optimized with Paintshop Pro's integrated PNG optimizer. Apparently it can be made even smaller than what Paintshop manages :-)
Edit based on OP's comment: Corel Paint Shop Pro is a photo editor, I guess you can call it a lightweight alternative to Photoshop. It was the quickest way for me to create a png comparabable to op's example.
As for what optimizer is best: some good old fashioned testing and comparing should tell you a lot, I wouldn't be surprised to see that the performance of individual optimizers depends on the input characteristics - eg some will do better on photos than others but on computer imagery it's the other way around, based on the algorithms used.
Aside from the compression ratio the ease with which you can integrate the optimizer in your workflow should be considered quite important.