Save profile of the same image

Hello to everyone,
Every week I get 300 samples like the one on the photo and I have to compare them to each other based on the gray levels. Therefore I wrote this macro to plot the profile of different lines along the samples that are in a folder. But the problem is I have to give a name of the profiles for each sample. Is there a way to integrate a function that saves the plot with the image name and the corresponding number of the plot automatically, something like:
Plot 1 of Image 1
Plot 2 of Image 1

Plot 5 of Image 7

This is the Macro I wrote:

// This macro processes all the images in a folder and any subfolders.

run(“Clear Results”);
extension = “.JPG”;
dir1 = getDirectory("Choose Source Directory ");

//first a dialog box opens to ask what should be analysed

Dialog.create(“Options”);
Dialog.addChoice(“sample lenght”, newArray(“305”, “315”, “350”));
Dialog.addCheckbox(“whole sample”, false);
Dialog.addCheckbox(“Plot Profile”, false);
Dialog.addCheckbox(“mean of small rectangles”, false);
Dialog.show();
sample = Dialog.getCheckbox();
profile = Dialog.getCheckbox();
mean = Dialog.getCheckbox();

setBatchMode(true);

n = 0;
processFolder(dir1);

function processFolder(dir1)
//processes all images in the folder
{
DataParameters = Dialog.getChoice();

list = getFileList(dir1);

 for (i=0; i<list.length; i++) 

{
if (endsWith(list[i], “/”))

          processFolder(dir1+list[i]);

      else if (endsWith(list[i], extension))

         processImage(dir1, list[i]);

}

}

function processImage(dir1, name)
//processing routine
{
open(dir1+name);

run(“8-bit”);
run(“Set Measurements…”, “display label area mean standard min area_fraction redirect=None decimal=3”);

if (DataParameters ==305) {

if (profile==true) {

g=getNumber("Plotnummer", 10);

g=g+1;
makeLine(400, 70, 400, 1240);
run ("Plot Profile");
DataEnd = ".tif";
saveAs("Tiff", dir1+g+DataEnd);
close();
g = g + 1;

makeLine(700, 70, 700, 1240);
run ("Plot Profile");
DataEnd = ".tif";
saveAs("Tiff", dir1+g+DataEnd);
close();
g = g + 1;

makeLine(1000, 70, 1000, 1240);
run ("Plot Profile");
DataEnd = ".tif";
saveAs("Tiff", dir1+g+DataEnd);
close();
g = g + 1;

makeLine(1300, 70, 1300, 1240);
run ("Plot Profile");
DataEnd = ".tif";
saveAs("Tiff", dir1+g+DataEnd);
close();
g = g + 1;

makeLine(1600, 70, 1600, 1240);
run ("Plot Profile");
DataEnd = ".tif";
saveAs("Tiff", dir1+g+DataEnd);
close();
g = g + 1;

}

if(sample==true) {
run(“ROI Manager…”);
setThreshold(163, 250);
makePolygon(69,3,180,1356,519,1350,408,0);
roiManager(“Add”);
roiManager(“Measure”); //does the measurement
roiManager(“Delete”);
resetThreshold; }

} else if (DataParameters == 315) {

run(“ROI Manager…”);
setThreshold(163, 255);

if (mean==true) {
makeRectangle(873, 90, 222, 378);
roiManager(“Add”);
roiManager(“Measure”);
roiManager(“Delete”);

makeRectangle(876, 459, 222, 360);
roiManager(“Add”);
roiManager(“Measure”);
roiManager(“Delete”);

makeRectangle(882, 816, 216, 411);
roiManager(“Add”);
roiManager(“Measure”);
roiManager(“Delete”);
}

if (sample==true) {
run(“ROI Manager…”);
setThreshold(163, 255);
makePolygon(881,97,897,1227,1110,1224,1093,93);
roiManager(“Add”);
roiManager(“Measure”);
roiManager(“Delete”); }
}

else if (DataParameters == 350) {

run(“ROI Manager…”);

if (sample==true) {
makeRectangle(1, 80, 45, 280);
roiManager(“Add”);

roiManager(“Measure”); //does the measurement

roiManager(“Delete”); }

}

//save results
DataName = getString(“LP_No”, “default”);
DataEnding = “_surface evaluation.csv”;
saveAs(“Results”, dir1+DataName+DataEnding); //Das Format ist noch nicht perfekt, muss später in Minitab importiert werden
run(“Clear Results”);
selectWindow(“Results”);
run(“Close”);