フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I save line 1 in all images

1 回表示 (過去 30 日間)
yen
yen 2011 年 5 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 日
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])

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by