0

I want to change figure name to name of the image I = imreadis reading in the following code:

I = imread("6hearts.jpg");
I = rgb2gray(I);

[Ir, Ic]=size(I);
if (Ic > Ir)
    I = imrotate(I,270);
end

srcFile = dir('C:\Users\umut8\Desktop\Deneme2*.jpg');
for i = 1:length(srcFile)
    filename = strcat("C:\Users\umut8\Desktop\Deneme2",srcFile(i).name);
    T = rgb2gray(imread(filename));
    [Tr, Tc]=size(T);
    temp = 0;
    if (Tc > Tr)
        T = imrotate(T,270);
        Temp = Tc;
        Tc = Tr;
        Tr = Temp;
    end
    R = normxcorr2(T,I);

    if (find(R > 0.75))
        R = imcrop(R,[Tc Tr Ic Ir]);
        [r, c, v] = find(R==(max(max(R))));
        RGB = insertShape(I, 'rectangle',[c, r, Tc, Tr],'LineWidth', 3, "Color", "Red" ,'Opacity',0.7 );

        figure(3);
        imshow(RGB)
    end
end

I want the title of the figure3 to be the "6hearts" in this spesific example.

Umut K.
  • 91
  • 1
  • 1
  • 8

1 Answers1

1

You may want to add a title(filename) to your code. Depending on what you are intending, you can call a break afterwards to end the for-loop as soon as you found a matching template. If not, it might be helpful to open separate figures and give them distinct names, e.g. figure('Name' , strcat("6hearts: ", filename))

max
  • 3,915
  • 2
  • 9
  • 25