JPEG file into an array

7 vues (au cours des 30 derniers jours)
Owen
Owen le 29 Mar 2015
Déplacé(e) : DGM le 17 Jan 2024
Hi,
is it possible to convert an JPEG file into an array in Matlab? What about the reverse conversion?
Owen

Réponse acceptée

Geoff Hayes
Geoff Hayes le 29 Mar 2015
Owen - when you read the JPEG image with imread the output from this function is an array. For example,
A = imread('myImg.jpg');
A is a matrix (multi-dimensional array). You can then use imwrite to save the matrix/array as a JPEG.
  4 commentaires
Image Analyst
Image Analyst le 30 Mar 2015
Déplacé(e) : DGM le 17 Jan 2024
You're checking the size on disk, which will always be less. Once it's decompressed and read into a variable in your MATLAB program, it will be its full uncompressed size. To get the compressed matrix, which virtually no one ever does or ever needs to do unless you're writing your own version of imread(), then you'd have to use fread(). Of course it's not an image at that point since you'd need to decompress it.
Owen
Owen le 31 Mar 2015
Déplacé(e) : DGM le 17 Jan 2024
I tried fread() and it gives the 18.6KB size.
Owen

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Import, Export, and Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by