How do I read the image of the half of a sequence of images?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Image Analyst
2014 年 7 月 10 日
編集済み: Image Analyst
2014 年 7 月 10 日
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 件のコメント
Image Analyst
2014 年 7 月 10 日
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?');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!