Borrar filtros
Borrar filtros

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

8 visualizaciones (últimos 30 días)
Felix123
Felix123 el 23 de Oct. de 2017
Respondida: Felix123 el 2 de Nov. de 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 comentario
Arvind Narayanan
Arvind Narayanan el 27 de Oct. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Felix123
Felix123 el 2 de Nov. de 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

Categorías

Más información sobre Call Web Services from MATLAB Using HTTP en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by