Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How can I save line 1 in all images

1 visualización (últimos 30 días)
yen
yen el 25 de Mayo de 2011
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentarios
Jan
Jan el 25 de Mayo de 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 el 25 de Mayo de 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

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 25 de Mayo de 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])

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by