필터 지우기
필터 지우기

How can i modified the name of my output image?

조회 수: 2 (최근 30일)
Simon Dussault
Simon Dussault 2013년 1월 30일
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

채택된 답변

Image Analyst
Image Analyst 2013년 1월 30일
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개)

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by