From: Krzysztof on
Hello,

I try to write script that will read file from disk. The TIFF file. I
have 2000 pictures in .tif, named from "photo.000000.tif" to
"photo.001999.tif"
And I want to make to every file medfilt2 function, medfilt2( , [5
5]);
and save every file in the same folder and same name.

Any help?
From: ImageAnalyst on
On Oct 13, 2:10 pm, Krzysztof <kprzychod...(a)gmail.com> wrote:
> Hello,
>
> I try to write script that will read file from disk. The TIFF file. I
> have 2000 pictures in .tif, named from "photo.000000.tif" to
> "photo.001999.tif"
> And I want to make to every file medfilt2 function, medfilt2( , [5
> 5]);
> and save every file in the same folder and same name.
>
> Any help?

-----------------------------------------------------------------------------
It's dangerous to overwrite your original files with filtered
versions. You'd be better off pcking a new filename, even if you have
backups of the originals or even if the new files are in a different
folder.
That said, you can use dir() to get the filenames, and sprintf() to
build up new ones. You may also find fileparts() and fullfile()
useful. And you may find section 4.12 of the MATLAB FAQ useful
http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Krzysztof on
Yes I know it is dangerous, but I have back up.

I figured out something like that:

file ='path to file/ photo.00' ;

for n = 1:2000

if i < 10
p = [file, '000' , int2str(i) ,'.tif'];
elseif i < 100
p = [file, '00' , int2str(i) ,'.tif'];
elseif i < 1000
p = [file, '0' , int2str(i) ,'.tif'];
else
p = [file, int2str(i) ,'.tif'];
end

%but here I don't know what to type, to use medfilt2 function for each
photo, and save to file.

end

end

I sholud mention that each file of these .tif is size of 2.5 MB.



On Oct 13, 9:12 pm, ImageAnalyst <imageanal...(a)mailinator.com> wrote:
> On Oct 13, 2:10 pm, Krzysztof <kprzychod...(a)gmail.com> wrote:
>
> > Hello,
>
> > I try to write script that will read file from disk. The TIFF file. I
> > have 2000 pictures in .tif, named from "photo.000000.tif" to
> > "photo.001999.tif"
> > And I want to make to every file medfilt2 function, medfilt2( , [5
> > 5]);
> > and save every file in the same folder and same name.
>
> > Any help?
>
> --------------------------------------------------------------------------- --
> It's dangerous to overwrite your original files with filtered
> versions.  You'd be better off pcking a new filename, even if you have
> backups of the originals or even if the new files are in a different
> folder.
> That said, you can use dir() to get the filenames, and sprintf() to
> build up new ones.  You may also find fileparts() and fullfile()
> useful.  And you may find section 4.12 of the MATLAB FAQ usefulhttp://matlabwiki.mathworks.com/MATLAB_FAQ

From: ImageAnalyst on
On Oct 13, 3:38 pm, Krzysztof <kprzychod...(a)gmail.com> wrote:
> %but here I don't know what to type, to use medfilt2 function for each
> photo, and save to file.
>
----------------------------------------
Is there something about the documentation for medfilt2, imread, and
imwrite that is confusing you???? It seems rather straightforward.
You pass in an array, and filename (if needed), and it does its
thing. Can you really not understand it?
From: Krzysztof on
On Oct 14, 12:29 am, ImageAnalyst <imageanal...(a)mailinator.com> wrote:
> On Oct 13, 3:38 pm, Krzysztof <kprzychod...(a)gmail.com> wrote:> %but here I don't know what to type, to use medfilt2 function for each
> > photo, and save to file.
>
> ----------------------------------------
> Is there something about the documentation for medfilt2, imread, and
> imwrite that is confusing you????  It seems rather straightforward.
> You pass in an array, and filename (if needed), and it does its
> thing.  Can you really not understand it?


Yes I can't understand it. You have expirience in matlab, as you wrote
in your profile, so this is simple for you. but for me it is not.

I write something like that:


f = dir('path to files/*.tif');

for i = 1:10
filename = f(i).name;
data = imread(filename);
data2 = medfilt2(data, [5 5]);
imwrite(data2, filename);
end

but still I have problem with writing files, because this script made
one file, and every calculations of medfilt2 write to that one file.
And I want to do new 2000 files or to overwrite existing once.