Using cell array for imwrite

4 Ansichten (letzte 30 Tage)
Matt Kernan
Matt Kernan am 7 Mär. 2017
Beantwortet: Jan am 7 Mär. 2017
How can i use cell array inside the imwrite?
Please help
  1 Kommentar
Stephen23
Stephen23 am 7 Mär. 2017
@Matt Kernan: you are storing image data in a cell array? Why? That would be quite inefficient.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 7 Mär. 2017
K = cell(3,1) ;
K{1} = rand(100) ;
K{2} = rand(200) ;
K{3} = rand(500) ;
for i = 1:length(K)
imwrite(K{1},strcat('image_K',num2str(i),'.jpg')) ;
end
  2 Kommentare
Matt Kernan
Matt Kernan am 7 Mär. 2017
Thanks. But it is not working. When i run it, it gives me following error
"Expected DATA to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was cell."
Jan
Jan am 7 Mär. 2017
@Matt: No, this is not possible. If you run KSSV's code, you cannot get this error. Please post the code you run, such that an improvement can be suggested.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jan
Jan am 7 Mär. 2017
You cannot use a cell as input for imwrite. I cannot imagine the intention of doing this. Writing images is only useful for images, and images are either [Col x Row] or [Col x Row x 3] numerical arrays. So perhaps you want to deliver the contents of a cell element to the imwrite command. Then see KSSV's answer, which answers this question, as far as I can see.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by