I have a bmp image and when i converted the image to jpg image using OpenCV and Paint, the two jpeg images looks same but while doing comparison they are different, even the file sizes are different.
I take the image from this link.
And Saved it on my PC, and then i used mspaint to edit this image and save it as jpeg, the file size of this image is 356kb.
And when i used OpenCV to load the original downloaded bmp image and then saved the image as jpg, then the file size is 408kb.
When i used Beyond Compare to compare these images, the result is as follow:
Can anyone please help me in understanding this.
Why I Want this
Actually one of my colleague is capturing images using a pc application for preparing a database of images, so he is capturing the image using key F3 (Shortcut for capturing image in that software) and then click on File -> Save As -> Change the Type of Image of to JPG and then rename it as 0001---9999.jpg and finally save the image.
The problem with this Software is that if we press the F3 and then Ctrl+S, it saves the file as bmp and with the name as time-stamp.
So what i told my friend that, just click F3 and Ctrl+S (so that he can take many pictures for database) and then i will write a python script which will convert all the bmp files into jpg and rename them from 0000-9999. And this part is completed but then i came to know about the problem i shared above.
The database will be used with OpenCV.
Please suggest the reasons for this.
JPEG compression is a lossy compression. The fact that you have different output sizes already suggests that you have different compression rates. Therefor you cannot expect identical results.
The standard does not specify any quantization precision.
The maths involved in the compression (like the discrete cosine transform) require several approximations. For example how many digits will you use for Pi? How will you approximate cosine?...
All those things may differ between different implementations so even if you have the same compression rate you are not guaranteed to get identical results.
Read https://en.wikipedia.org/wiki/JPEG (and the standards) if you are interested in more details.
So unless you run both images through the same software it is unlikely that you will get what you want. Even in the same software there might be differences.
Related
I am working on Image processing with deep learning and I came on to the topic Error level Analysis which gives/shows the difference in compression level(I'm trying to show if the image as gone under multiple compressions or not) in JPEG (lossy compression).
Are there any other techniques which are similar to ELA on JPEG and techniques similar or different which can be used on PNG as well to show multiple compressions?
There cannot be, IMHO.
Since PNG compression is lossless, every decompression must result in the identical original image. Therefore, every recompression will start from the same place so no history can be retained.
Im thinking to use the Huffman coding to make an app that takes pictures right from the iPhone camera and compress it. Would it be possible for the hardware to handle the complex computation and building the tree ? In other words, is it doable?
Thank you
If you mean the image files (like jpg, png, etc), then you should know that they are already compressed with algorithms specific to images. The resulting files would not huffman compress much, if at all.
If you mean that you are going to take the UIImage raw pixel data and compress it, you could do that. I am sure that the iPhone could handle it.
If this is for a fun project, then go for it. If you want this to be a useful and used app, you will have some challenges
It is very unlikely that Huffman will be better than the standard image compression used in JPG, PNG, etc.
Apple has already seen a need for better compression and implemented HEIF in iOS 11. WWDC Video about HEIF
They did a lot of work in the OS and Photos app to make sure to use HEIF locally, but if you share the photo it turns it into something anyone could use (e.g. JPG)
All of the compression they implement uses hardware acceleration. You could do this too, but the code is a lot harder than Huffman.
So, for learning and fun, it's a good project -- it might be easier to do as a Mac app instead, but for something meant to be real, it would be extremely hard to overcome the above issues.
There are 2 parts, encoding and decoding. The encoding process involves constructing a tree or a table based representation of a tree. The decoding process covers reading from huff encoding bytes and undoing a delta. It would likely be difficult to get much speed advantage in the encoding as compared to PNG, but for decoding a very effective speedup can be seen by moving the decoding logic to the GPU with Metal. You can have a look at the full source code of an example that does just that for grayscale images on github Metal Huffman.
We’ve been asked to consider how Instagram structures their image upload on iOS. Instagram compresses to a max 1080 x1350 and I've tried to achieve their image quality with those parameters using
UIimagejpegrepresentation
Does anyone know if they're likely to use apple's standard JPEG compression above or something custom/better?
The way to find out is to take some Instragram JPEGs. Then run a JPEG dumping program on them.
Check the following to see if they are the same in all images:
Huffman tables in the DHT markers
The type of SOF marker used
The sampling rates in the SOF markers
The quantization tables in the DQT markers
If they are using a progressive SOF marker:
The number of scans and their header values.
That will tell you if Instagram uses one thing. If it is, it is likely to be different from what you get from Apple.
I was wondering if the type of photo used to train an object detector makes a difference, I can't seem to find anything about this online. I am using opencv and dlib if that makes a difference but I am interested in a more general answer if possible.
Am I correct in assuming that lossless file formats would be better than lossey formats? And if training for an object jpg would be better than png as pngs are optimized for text and graphs?
As long as the compression doesn't introduce noticeable artifacts it generally won't matter. Also, many real world computer vision systems need to deal with video or images acquired from less than ideal sources. So you usually shouldn't assume you will get super high quality images anyway.
I am running fedora 11.
I seek to identify the characters indicating the date on a satellite image, but its resolution was (deliberately?) deteriorated.
The goal is to automate this procedure. For that I use ocr program tesseract.
It works perfectly on my PC with the scans, but in this case it does not work.
Here's what I did:
Address of the image:
(source: meteo.pf)
I convert in tiff format (used by tesseract, (bpp ok))
I use tesseract: tesseract societeir.tif test, but no output.
When I increase the image scaling, the ocr online work, but tesseract not.
Do you have a suggestion?
One suggestion,
Since the date on the image is most likely going to be in the same position and of the same dimension, you can try to cut it out and save it as another image using an image processing tool. I normally would use gimp, but leptonica, imagemagick are other tools that I can think of. The recognition should be better on the new image
Copy the date region into memory, run enhancements on it then run the OCR against it?