Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How can I save line 1 in all images

1 Ansicht (letzte 30 Tage)
yen
yen am 25 Mai 2011
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Jan
Jan am 25 Mai 2011
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 am 25 Mai 2011
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

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 25 Mai 2011
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])

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by