【问题标题】:How to change figure name to image name in Matlab [duplicate]如何在Matlab中将图形名称更改为图像名称[重复]
【发布时间】:2023-04-10 18:51:02
【问题描述】:

我想将图形名称更改为图像名称I = imread正在阅读以下代码:

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

我希望figure3 的标题在此特定示例中为“6hearts”。

【问题讨论】:

  • 你在找函数title()吗?
  • 是的,但是我如何在循环中使用匹配的模板名称更改标题名称?
  • 只需传递您想要的任何名称作为参数。

标签: matlab image-processing


【解决方案1】:

您可能想添加一个 title(filename) 到你的代码。根据您的意图,您可以在找到匹配模板后立即调用break 来结束for-循环。 如果没有,打开单独的图形并给它们起不同的名称可能会有所帮助,例如figure('Name' , strcat("6hearts: ", filename))

【讨论】:

    猜你喜欢
    • 2014-05-31
    • 1970-01-01
    • 2014-08-14
    • 2018-10-05
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    • 2011-01-13
    相关资源
    最近更新 更多