Parameterize Image Name In Function

조회 수: 7 (최근 30일)
muath shaikh
muath shaikh 2014년 12월 18일
답변: muath shaikh 2014년 12월 18일
Hello Colleagues, I have Function with parameter image name, inside the function i want to write image after some of editing, but i want to take part from image name and add another part as imwrite image name for example
function editing (ImageName)
w=imread(ImageName);
w=double(w);
w=w+0.02;
w=uint8(w);
imwrite(w,'w_ImageName.jpg','jpg');
end
I want the new image name to be w letter with image name.

채택된 답변

Joseph Cheng
Joseph Cheng 2014년 12월 18일
So what you can do is strip the extension off of the ImageName string variable.
function editing (ImageName)
w=imread(ImageName);
w=double(w);
w=w+0.02;
w=uint8(w);
ImageName=ImageName(1:end-4); %strip off the extension;
imwrite(w,['w_' ImageName '.jpg'],'jpg'); %concatenate your prefix and new extension.
end
  댓글 수: 1
muath shaikh
muath shaikh 2014년 12월 18일
It seems ImageName variable in line ImageName=ImageName(1:end-4); %strip off the extension; will store the image pixels values not the image name itself;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

muath shaikh
muath shaikh 2014년 12월 18일
Thank you for your helping, It solved by adding this line ImageName =ImageName; at the first of the function like this :
function editing (ImageName)
ImageName =ImageName;
w=imread(ImageName);
w=double(w);
w=w+0.02;
w=uint8(w);
ImageName=ImageName(1:end-4); %strip off the extension;
imwrite(w,['w_' ImageName '.jpg'],'jpg'); %concatenate your prefix and new extension.
end

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by