How do I read the image of the half of a sequence of images?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have this code.
Carpeta='C:\Users\karina\Documents\MATLAB\11';
if ~isdir(Carpeta)
errorMensaje = sprintf('Error: La Carpeta no existe:\n%s', Carpeta);
uiwait(warndlg(errorMensaje));
return;
end
filePatron = fullfile(Carpeta, '*.jpg');
jpegFil = dir(filePatron);
Mitad=length(jpegFil)/2;
MitadR=round(Mitad);
A=num2str(MitadR);
base=[A,'.jpg'];
ImagenOriginal=imread(base);
%Convertir a escala de Grises
imOrGris=rgb2gray(ImagenOriginal);
%Versión binaria por el método de Otsu
Ib=graythresh(imOrGris);
BN = im2bw(imOrGris,Ib);
%Se aplica una máscara de 25 x 25 pixeles
Ibmask=medfilt2(BN,[25 25]);
%Se elige la región ROI
iROI=roicolor(Ibmask,1);
imcrop(iROI)
But my series name is 'MVI_1211 X.jpg' where X is a number from 1 to 45. Then what I want is to read only the image in the middle, in this case the image 23. It would be 'MVI_1211 23.jpg' instead of 23.jpg which I don't have. I don't want write MVI_1211 to complete the name because it has to function with different folders and series. Thank you for your time. Regards.
0 commentaires
Réponse acceptée
Image Analyst
le 10 Juil 2014
Modifié(e) : Image Analyst
le 10 Juil 2014
Call dir(), sort(), etc.
filenames = dir('MVI_1211*.jpg');
% Extract out just the names into a cell array.
names = struct2cell(filenames);
names = lower(names(1,:))
% Then call sort()
sortedList = sort(names)
% Then get the number of strings. Then get the halfway item
middleIndex = floor(length(sortedList)/2)
% Get the middle filename.
middleFileName = sortedList(middleIndex)
2 commentaires
Image Analyst
le 10 Juil 2014
And then (for fun)
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
obj.Volume = 100;
Speak(obj,'MATLAB is an awesome programming language, dont you think, care reena?');
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!