pathname ='D:\dataset\' ;
dirlist = dir( [pathname '*.jpg'] );
pickind='jpg';
for x = 1:length(dirlist)
I = imread([pathname, dirlist(x).name]);
I=imresize(I,[256 256]);
size(I)
m = mean(I(:));
I1=double(I);
V = var(double(I(:)));
J = stdfilt(I);
SD = std(double(I(:)));
result=[m V SD];
final_col2{k}=result;
end
save('new','final_col2');
please tell how to write a function file for this and call it in a main file

댓글 수: 5

TAB
TAB 2012년 1월 5일
final_col2{k}=result
k = ?
kash
kash 2012년 1월 5일
sorry Tabrez it is x
final_col2{x}=result
Titus Edelhofer
Titus Edelhofer 2012년 1월 5일
Hi Kash,
this is more or less the same question as
http://www.mathworks.com/matlabcentral/answers/25354-error-in-writing-function-file
Perhaps we continue the discussion there ...
Titus
kash
kash 2012년 1월 5일
titus no one answered there also,cau u explain here plz
Walter Roberson
Walter Roberson 2012년 1월 5일
Please do not start new questions just because no one has answered a previous question. You can post reminders, and you can edit questions to reflect current situations.

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

 채택된 답변

TAB
TAB 2012년 1월 5일

1 개 추천

Here there is one input in the code which is pathname and your final output is final_col2. So you can make a function as
function FinalOut = MyFunc(InputPath)
pathname = InputPath;
dirlist = dir( [pathname '*.jpg'] );
...
...
...
...
final_col2{k}=result;
end
save('new','final_col2');
FinalOut = final_col2;
end
Also 'final_col2' should be initialized before starting the loop for efficiency purpose.
final_col2=cell(length(dirlist),1)

댓글 수: 2

kash
kash 2012년 1월 5일
Thanks Tabrez,but how to call this in main file
TAB
TAB 2012년 1월 5일
Hope, your 'main file' is another matlab function or script.
You can call above function as
RetData=MyFunc('D:\dataset\');
If you are not aware of Matlab functions, please see
http://www.mathworks.com/help/techdoc/matlab_prog/f7-38085.html

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2012년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by