How can I save line 1 in all images

I have an image directory consist I1, I2,....In same size I1=[1 1 1 0;1 1 1 0;1 1 1 0]; I2=[1 0 1 0;1 0 1 0;1 0 1 0]; .... In=[1 1 0 1;1 1 0 1;1 1 0 1]; how can I save data=[1 1 1 0; 1 0 1 0;....1 1 0 1]( 1 1 1 0: line 1 of image I1,....1 1 0 1: line 1 of image In)

댓글 수: 2

Jan
Jan 2011년 5월 25일
What is "an image directory"? What does "save data" mean in your problem? Why do you use "l1", "l2", ... instead of a 3D array? Then getting the 1st line would be trivial.
yen
yen 2011년 5월 25일
my image directory contain 44 image same size 49x50, all image is barcode image have black bars is 0, white bars is 1
This is my code:
function [data targets]=docmau()
myFolder = 'Tapmau';
filePattern = fullfile(myFolder, '*.bmp');
bmpFiles = dir(filePattern);
size=length(bmpFiles);
for k = 1:length(bmpFiles)
baseFileName = bmpFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
mang{k}=imread(fullFileName);
% imshow(imageArray); % Display image.
% drawnow;
% Force display to update immediately.
end
for i = 1:length(bmpFiles)
matrix{i}=reshape(mang{i},[],1);
matrix{i}=double(matrix{i});
%k=length(data{i})
end
data=matrix{1};
for i = 2:length(bmpFiles)
data=[data matrix{i}];
end
targets=eye(44);
I want get matrix{i} is 2d array contain only line1 because all my image have same lines

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2011년 5월 25일

0 개 추천

I1=[1 1 1 0;1 1 1 0;1 1 1 0];
I2=[1 0 1 0;1 0 1 0;1 0 1 0];
In=[1 1 0 1;1 1 0 1;1 1 0 1];
variant 1
I = [I1 I2 In];
data = reshape(I(1,:),size(I1,2),[]).'
variant 2
I = cat(3,I1,I2,In);
data = permute(I(1,:,:),[3 2 1])

이 질문은 마감되었습니다.

태그

질문:

yen
2011년 5월 25일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by