How can i modified the name of my output image?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, i want to know how can i change the name of a image when im saving it in another folder? Im doind some image processing with thresholding and i want to save my image where there's a ROI into a folder with a certain name. Right now, i got 1000 images name "image00000, image00001, ...." and i want to change it to "Frame0, Frame1, Frame 2, ...." Can someone help me please
Here's my code right now:
clear all; close all;
% Go get all my Jpgs in my folder
files=dir('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\*.jpg');
addpath('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test');
addpath('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter');
%Batch processing loop
for k=1:numel(files)
img=imread(files(k).name);
img1=imresize(img,[800 800]);
img2=rgb2gray(img1); imgBW=im2bw(img1); mask = imopen(imgBW, strel('Disk',1)); mask1 = imfill(mask,'holes'); [L Ne]= bwlabel(mask1); propied=regionprops(L,'basic');
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','r','LineWidth',2)
end
s=find([propied.Area]>500 & [propied.Area]<1000);
for n=1:size(s,2)
rectangle('Position',propied(s(n)).BoundingBox,'EdgeColor','g','LineWidth',2)
end
output_name=['C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter\' files(k).name];
imwrite(mask1, ['C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter\' files(k).name]);
end
0 commentaires
Réponse acceptée
Image Analyst
le 30 Jan 2013
Use sscanf() to extract the number out of the filename. Then use
newBaseFileName = sprintf('Frame%d', theNumber);
fullFileName = fullfile(theFolder, newBaseFileName);
to create the new filename.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Segmentation and Analysis 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!