I have a question about how can I create a loop. I'm going to try to simplify. I have three images (the real problem has a huge images). For example:
image1.tif
image2.tif
image3.tif
On the other hand, I have a text file (I cannot introduce this on the code directly because it has been generated with other process) with two different parameters for each image. For example:
Parameterimage1_1= 1.2; %corresponds to image1
Parameterimage1_2= 2.3; %corresponds to image1
Parameterimage2_1= 5.3; %corresponds to image2
Parameterimage2_2= 2.4; %corresponds to image2
(...)
What I need to do is to read the text file and then, apply two different parameters for each image in a loop. What I have done is the following:
Image1= imread ('image1.tif');
Image2= imread ('image2.tif');
Image3= imread ('image3.tif');
Data= READINGPARAMETERS(parameters)
param1= Data.param1;
param2= Data.param2;
param3=Data.param3;
(...)
Image1_out= param1*Image1/param2;
Image2_out= param3*Image1/param4;
imwrite(Image1_out, 'G:\Image1_out.tiff','tiff');
imwrite(Image2_out, 'G:\Image2_out.tiff','tiff');
function [Data] = READINGPARAMETERS(parameters)
fid = fopen(parameters); % I have defined the path previously
text = fscanf(fid, '%c');
posini= strfind(text,'=');
posfin= strfind(text,';');
Datos.param1= str2num(texto(posini(1)+1 : posfin(1)-1));
Datos.param2= str2num(texto(posini(2)+1 : posfin(2)-1));
Datos.param3= str2num(texto(posini(3)+1 : posfin(3)-1));
(...)
return
My question is that I don't know how to create the loop for that. Usually, I do it in that way but I don't know how to indicate that has to take the two parameters.
for k = 1:length(tifFiles)
baseFileName = tifFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
AND here the process
imwrite(imageArray, fullFileName);
It is possible to find the parameters by name? (I mean, for example in a excel file to take the values for the same name as the image). I don't know how to automatize that.
Any kind of help would be appreciated,
Greetings,