Convert a PNG to a double matrix
Ältere Kommentare anzeigen
I have a matrix of double type values. I convert it to a PNG with saveas, now I would like to return it back to a double matrix. Is that possible? I understand that a PNG file has 16 billion levels and to convert it back to a double should be possible. If one converts a double matrix to a PNG why cant we work backwards? Larry
1 Kommentar
Larry
am 6 Sep. 2019
Antworten (1)
Walter Roberson
am 10 Jul. 2017
0 Stimmen
If the original values you saved were between 0 and 1, then you can use im2double() to get approximations of them back.
If the original values you saved were outside 0 to 1 and were an integer data type, then imread() should have returned the values (though I would need to recheck what happens for negative values in integer data type)
If the original values you saved were outside 0 to 1 and were double(), then most of the data is probably gone, not recoverable.
2 Kommentare
Larry
am 10 Jul. 2017
Walter Roberson
am 10 Jul. 2017
Instead of doing that,
filename = sprintf('%sVS%dL%d', opath, k, LL);
ind = im2uint8(mat2gray(YourData, [0 55]);
cmap = colormap();
imwrite(ind, cmap, filename);
Then to recover,
[ind, cmap] = imread(filename);
orig_val = im2double(ind) * 55;
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!