Borrar filtros
Borrar filtros

I saved pixel values of a gray scale image 48x48 which is a picture of face, now i want to save these pixel values back into an image(gray face image), Can this be done?? if yes, then tell me kindly how??

1 visualización (últimos 30 días)
img = imread('face.jpg');
fid = fopen('pixels.txt', 'w');
if fid == -1, error('Cannot open file'); end
fprintf(fid, '%d %d %d ', size(img));
fprintf(fid, '%g ', img(:));
fclose(fid);

Respuestas (1)

Rik
Rik el 4 de Nov. de 2017
You can read back the file (just use your favorite internet search engine to find a myriad of people asking how to do so). You can then use reshape to shape it back to your original image.
IM_double=reshape(IM_from_file,48,48);
IM_original=uint8(IM_double);

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by