将 jpg 文件名添加到列表框和 select 一个用于观看 - Matlab

Add jpg file names to a list box and select one for watching - Matlab

如何从此列表框中读取选定的 jpg 并在轴中查看它?

    function selectFolderButtonPushed(app, event)
        app.selectedPath = uigetdir();
        jpgFileInfo = dir(fullfile(app.selectedPath, '*.jpg'));
        app.jpgListBox.Items =  {jpgFileInfo.name}';
    end


    function loadimageButtonPushed(app, event)
        imageSelected = imread(......);
        imshow(imageSelected, app.imageAxes);
    end

希望对您有所帮助:

function SelectFolderButtonPushed(app, event)
            app.selectedPath = uigetdir();
            jpgFileInfo = dir(fullfile(app.selectedPath, '*.jpg')) 
            app.jpgListBox.Items =  {jpgFileInfo.name}'; 
        end
 
        function loadimageButtonPushed(app, event)
            selectedFileName = app.jpgListBox.Value;
            selectedPath = app.selectedPath;
            imageSelected =strcat(selectedPath, "\", selectedFileName)
            imshow(imageSelected,'Parent',app.imageAxes); 
        end