image thumbnail


version (1.08 KB) by Evgeny
decodes encoded JPEG array into a Matlab array (image)


Updated 29 Oct 2015

View License

I was looking for this functionality for some time, but all file exchange submissions seem to be some custom decoders
Then on stackoverflow I found a snippet which uses java for decoding:
This snippet worked for me and I am submitting it as a function here.

% get a stream of bytes representing an endcoded JPEG image
fid = fopen('football.jpg', 'rb');
data = fread(fid, Inf, '*uint8');

% decode jpeg
img = decodeJpeg(data);

% check results against directly reading the image using IMREAD
img2 = imread('football.jpg');
assert(isequal(img, img2))

Cite As

Evgeny (2022). decodeJpeg (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!