Decoding base64 data from a txt/xml file. base64decode is slow.
조회 수: 7 (최근 30일)
이전 댓글 표시
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
Arvind Narayanan
2017년 10월 27일
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?
답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!