Strings help! URGENT!!!
Afficher commentaires plus anciens
Im having problems with this code, i am trying to reading ten image files, i then want to average the files as i have done. This part works.
However after doing this i want to output ten files of a string which contains the ten images after they have been averages so i can view them individually.
%reading all ten images
fileread = {'image001.png' 'image002.png' 'image003.png' 'image004.png' 'image005.png' 'image006.png' 'image007.png' 'image008.png' 'image009.png' 'image001.png'};
for i = 1:10
fileread2{i} = sprintf('scan %.f', i);
end
% Input of a numerical threshold value
threshold = input('Enter a threshold value to estimate active bloodflow: ');
%determining whether the threshold value lies between the parameters
while threshold > 255 || threshold < 0
disp('The threshold value is not a valid value')
threshold = input('Enter a threshold value to estimate active bloodflow: ' );
end
%Analysing images 1:10
pixels = zeros(1:10);
for i = 1:10
images = imread(fileread{i});
pixels(i) = length(find(images > threshold));
fprintf('scan %s has %.f pixels above the threshold \n', fileread2{i}, pixels(i))
end
for i = 1:10
images = images(1:10);
for x = 2:199;
for y = 2:199
avg = [images(x-1, y-1:y+1); images(x, y-1:y+1); images(x+1, y-1:y+1)];
images(x,y) = mean2(avg);
end
end
end
Any assistance would be greatly appreciated...
Réponses (1)
Sean de Wolski
le 12 Mai 2011
pixels = zeros(1,10); % pixels(1:10) will create a 10D array with 10! elements.
Same with images
To save the images for viewing use a cell array:
the_images = cell(10,1);
for ii = 1:10
the_images{ii} = imread(...);
end
%to view image four
%imshow(the_images{4})
2 commentaires
Walter Roberson
le 12 Mai 2011
I think Sean meant:
pixels = zeros(1,10); %zeros(1:10) will create a 10D array with 10! elements
Sean de Wolski
le 12 Mai 2011
Thanks Walter. Note to self: don't log online prior to at least five gulps of coffee.
Catégories
En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!