Effacer les filtres
Effacer les filtres

Decoding base64 data from a txt/xml file. base64decode is slow.

8 vues (au cours des 30 derniers jours)
Felix123
Felix123 le 23 Oct 2017
I have a 2801x2801 sized image in a base64 notation that has been generated by some VB script and is then stored in an xml text file. I use the follwing code:
filename = 'measurement_data.txt'
xDoc = xmlread(filename);
% entries = TreeNode.getElementsByTagName('data');
entries = xDoc.getElementsByTagName('data');
% entries = entries1.getElementsByTagName('data');
data = zeros(52,52);
for k=1:entries.getLength-1
a = string(entries.item(k).getTextContent);
b = matlab.net.base64decode(strip(a,'right','='));
data(k,:) = typecast(b,'int16');
end
It takes between 20 and 30 seconds to read in the image and most of that time (99%) is spent using matlab.net.base64decode. It takes a little less than 10ms per call. I have attached a txt file with a smaller image (51x51) and for this image it only take 0.4 ms per call to base64decode. I am sure there must be a better/faster method. Any help is appreciated.
Thanks, Felix
  1 commentaire
Arvind Narayanan
Arvind Narayanan le 27 Oct 2017
Hi,
We would need the original image which you used to generate the XML file to be able to reproduce the issue. Currently, the code doesn't run for me as the image is missing, which leads to the b array being defined incorrectly. Am I missing something?

Connectez-vous pour commenter.

Réponses (1)

Felix123
Felix123 le 2 Nov 2017
Hey Arvind, thanks for having a look. The problem was, that I only put in a smaller image as an example, so I had to change the size of data. I updated the code and it should run now.
Felix

Catégories

En savoir plus sur Call Web Services from MATLAB Using HTTP dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by