How to extact bits from an image to a string separated with commas?

1 visualización (últimos 30 días)
mikel mikel
mikel mikel el 17 de Jun. de 2021
Editada: Jan el 18 de Jun. de 2021
Hello,
I am trying to get an image bits in a string separated with commas.
My code is the following:
Image = imread('calle1.png');
COL=640;
ROW=360;
a=zeros(1,COL*ROW);
n=1;
for i=1:1:ROW
for j=1:COL
a(1,n)=Image(i,j);
n=n+1;
end
end
% aCSV = regexprep(num2str(a), '\s*', ',');
allOneString = sprintf('%.0f,' , a);
allOneString = allOneString(1:end-1);% strip final comma
When I try to open the string it says: cannot display summaries of variables with more than 524288 elements. How can I do it?
Thanks

Respuestas (1)

Jan
Jan el 18 de Jun. de 2021
Editada: Jan el 18 de Jun. de 2021
Your code produces a CHAR vector (a "string" is a different class). Now you explain, that there is an error, when you "try to open the string". But what does this mean? Where do you try this in which way? What do you want to see?
A hint: You can replace:
COL=640;
ROW=360;
a=zeros(1,COL*ROW);
n=1;
for i=1:1:ROW
for j=1:COL
a(1,n)=Image(i,j);
n=n+1;
end
end
by:
a = reshape(Image.', 1, []);
But there is no need to do this. Simply use:
Image = imread('calle1.png');
allOneString = sprintf('%d,', Image.');
allOneString(end) = [];

Categorías

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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by