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.
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.
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.
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 trying to implement an algorithm for a system which the camera get 1000fps, and I need to get the value of each pixel in all images and do the different calculation on the evolution of pixel[i][j] in N number of images, for all the pixels in the images. I have the (unsigned char *ptr) I want to transfer them to the GPU and start implementing the algorithm.but I am not sure what would be the best option for realtime processing.
my system:
CPU Intel Xeon x5660 2.8Ghz(2 processors)
GPU NVIDIA Quadro 5000
I got the following questions:
I do I need to add any Image Processing library addition to CUDA? if yes what do you suggest?
can I create a matrix for pixel[i,j] containing values for images [1:n] for each pixel in the image size? for example for 1000 images with 200x200 size I will end up with 40000 matrix each
containing 1000 values for one pixel? Does CUDA gives me some options like OpenCV to have a Matrices? or Vector?
1 - Do I need to add any Image Processing library addition to CUDA?
Apples and oranges. Each has a different purpose. An image processing library like OpenCV offers a lot more than simple accelerated matrix computations. Maybe you don't need OpenCV to do the processing in this project as you seem to rather use CUDA directly. But you could still have OpenCV around to make it easier to load and write different image formats from the disk.
2 - Does CUDA gives me some options like OpenCV to have a Matrices?
Absolutely. Some time ago I wrote a simple (educational) application that used OpenCV to load an image from the disk and use CUDA to convert it to its grayscale version. The project is named cuda-grayscale. I haven't tested it with CUDA 4.x but the code shows how to do the basic when combining OpenCV and CUDA.
It sounds like you will have 40000 independent calculations, where each calculation works only within one (temporal) pixel. If so, this should be a good task for the GPU. Your 352 core Fermi GPU should be able to beat your 12 hyperthreaded Xeon cores.
Is the algorithm you plan to run a common operation? It sounds like it might not be, in which case you will likely have to write your own kernels.
Yes, you can have arrays of elements of any type in CUDA.
Having this being a "streaming oriented" approach is good for a GPU implementation in that it maximizes number of calculations as compared to transfers over the PCIe bus. It it might also introduce difficulties in that, if you want to process the 1000 values for a given pixel in a specific order (oldest to newest, for instance), you will probably want to avoid continuously shifting all the frames in memory (to make room for the newest frame). It will slightly complicate your addressing of the pixel values, but the best approach, to avoid shifting the frames, may be to overwrite the oldest frame with the newest frame each time a new frame is added. That way, you end up with a "stack of frames" that is fairly well ordered but has a discontinuity between old and new frames somewhere within it.
I do I need to add any Image Processing library addition to CUDA ???
if yes what do you suggest?
Disclosure: My company develop & market CUVILib
There are very few options when it comes to GPU Accelerated Imaging libraries which also offer general-purpose functionality. CUVILib is one of those options which offers the following, very suited for your specific needs:
CuviImage object which holds your image data and image as a 2D matrix
You can write your own GPU function and use CuviImage as a 2D GPU matrix.
CUVILib already provides a rich set of Imaging functionality like Color Operations, Image Statistics, Feature detection, Motion estimation, FFT, Image Transforms etc so chances are that you will find your desired functionality.
As for the question of whether GPUs are suited for your application: Yes! Imaging is one of those domains which are ideal for parallel computation.
Links:
CUVILib: http://www.cuvilib.com
TunaCode: http://www.tunacode.com