Image Compression

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Image Compression

Post by rp181 »

I have a 128x256 8-bit grayscale image read into the XMOS. I need a way to quickly transmit this over a wireless link. Right now, it takes more than 30 seconds. Does anyone know some image compression (JPEG) libraries written for embedded platforms?

I have 30kb free ram on the core, but i could use another core if needed.


User avatar
skoe
Experienced Member
Posts: 94
Joined: Tue Apr 27, 2010 10:55 pm

Post by skoe »

How good do these images compress with zlib (you can try it with gzip)? If you use a smaller compression window size than the default value it may fit into 30 kbyte. btw zlib is used by the PNG file format, but I guess you don't need the PNG container and it's okay for you to transfer a proprietary file format.

I have some doubts that a JPEG implementation or similar algorithms fit into 30 kbyte incl. data, but if a lossless method doesn't provide enough compression you could try it on a seperate core.

Let us know how you solved it.
User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

Actually you don't want PNG as its lossless and will try to recreate all the camera noise and such. PNG is great for drawings but for photos its compression is quite bad because of the level of detail. JPEG will get rid of the tiny details and make the image much much smaller, but it depends on what quantity you want. I also recommend in getting your radio link go a little faster since 1Kbit is quite slow for transferring images.
User avatar
jason
XCore Expert
Posts: 577
Joined: Tue Sep 08, 2009 5:15 pm

Post by jason »

Indeed JPG with highish quality is probably best as far as filesize goes - PNG for regular images takes up a lot of space.

Have attached some examples of PNG / JPG images of varying quality - note the file sizes!

I agree with Berni - 1Kbs is still going to take some time for a single frame.
You do not have the required permissions to view the files attached to this post.
User avatar
jason
XCore Expert
Posts: 577
Joined: Tue Sep 08, 2009 5:15 pm

Post by jason »

PS you might want to contact f_petrini as he is working on an Octocopter: http://xcore.com/forum/viewtopic.php?f=18&t=594 also recording video and such - may save time if he has already figured it out.
User avatar
f_petrini
Active Member
Posts: 43
Joined: Fri Dec 11, 2009 8:20 am

Post by f_petrini »

I'm using a dedicated 5.8GHz video link to transmit video and will only use the XK-1 to overlay graphics on the video signal.
Currently I'm using a GoPro Hero HD camera and an Iftron 25mW transmitter. On the ground I have a Iftron receiver connected to a pair of Fat Shark video goggles.

You may want to check these two jpeg libs if you haven't already seen them:
http://developer.berlios.de/projects/jpegant
http://sourceforge.net/projects/mb-jpeg
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Post by rp181 »

Thanks for replying!

My wireless link is a 1w transmitter. The transmitter is capable of 115,000 baud, but I am at 19200. I am having a problem with the buffer filling up, and loosing data every 2kb (the buffer size).

How costly is JPEG compression in terms of CPU? I havn't been able to look through the actuall algorithm yet. I have also "binned" the optical flow sensor into 2x2 "superpixels", so there is a fourth of the data (~6k). Noise should be significantly less once I implement a FPN mask. FPS shouldn't matter much, but help for debugging.

I have also just got basic sobel edge detection to work on the XMOS. I am going to work on feature detection soon. This should reduce amount of data.
User avatar
boeserbaer
Active Member
Posts: 51
Joined: Fri Jan 29, 2010 4:36 pm

Post by boeserbaer »

Regarding your buffer filling up, Is hardware handshaking an option? that should solve your buffer problem.

Regards, Mike
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Post by rp181 »

Do you mean handshaking on the RF link, or the modem-pc link? I am not sur where the data is getting lost. Imay have seen an option for that, I will check.
User avatar
skoe
Experienced Member
Posts: 94
Joined: Tue Apr 27, 2010 10:55 pm

Post by skoe »

Berni wrote:Actually you don't want PNG as its lossless
Of course I know the difference between lossy and lossless image compression. A few years ago I used JPEG compression on a mobile phone I developed software for. That's why my opinion is that it's a bit oversized for 30 kBytes code and data and also much more CPU hungry than most lossless algorithms.

But you are right, at 1 kbps it's best to use a wavelet encoder :) That's why in this case it may be useful to try JPEG, especially if there is another core free.