how to store values in second column of cell array

In the following program, I get the value 200 X 1 after reshaping function, I want to store ground truth a label like 1 1 1 1 1 for the first five images then second 2 2 2 2 2 up to 40 images e.g.
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 2
1600x1 uint8 2
1600x1 uint8 2
1600x1 uint8 2
1600x1 uint8 2
.
.
1600x1 uint8 40
1600x1 uint8 40
1600x1 uint8 40
1600x1 uint8 40
1600x1 uint8 40
clc;
clear all;
faceData = cell(40,5); % or cell(5,40)
for i=1:40
cd(strcat('s',num2str(i)));
for j=1:5
v=imread(strcat(num2str(j),'.bmp'));
v1 = imresize(v,[40,40]);
[x1,y1] = size(v1);
v1=v1(:); % it make long vertical vector
w = uint8(v1);
faceData{i,j} = w;
end
cd ..
end
faceData = reshape(faceData,[],1);

댓글 수: 6

size(yourcell) ?
now it is 200 X 1 but i want 200 X 2 in second column i require
1
1
1
1
1
2
2
2
2
2
.
.
40
40
40
40
40
faceData = reshape(faceData,[],2);
2 columns ! Does it answer you?
yes sir, but in second column values are again 1600 X 1 are stored instead of that I want to store values like
1
1
1
1
1
2
2
2
2
2
.
.
.
40
40
40
40
40
First five images one then second five images two up to last 200
images 40
200/5 = 40, therefore,
faceData = reshape(faceData,[],40);
no sir that will create 40 column, I just want my cell array like
First column second column
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 1
1600x1 uint8 2
1600x1 uint8 2
1600x1 uint8 2
1600x1 uint8 2
1600x1 uint8 2
.
.
1600x1 uint8 40
1600x1 uint8 40
1600x1 uint8 40
1600x1 uint8 40
1600x1 uint8 40

댓글을 달려면 로그인하십시오.

 채택된 답변

Kevin Chng
Kevin Chng 2018년 10월 21일
편집: Kevin Chng 2018년 10월 21일
for i=1:1:length(faceData)
faceData{i,2}=ceil(i/5);
end
Add the code above to the below of your code.
Kindly accept my answer if it is working for you.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2018년 10월 21일

댓글:

2018년 10월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by