Skip to content

Instantly share code, notes, and snippets.

@gyk
Last active August 29, 2015 14:08
Show Gist options
  • Save gyk/d3f2d2879515ede4e362 to your computer and use it in GitHub Desktop.
Save gyk/d3f2d2879515ede4e362 to your computer and use it in GitHub Desktop.
Display three images in Matlab
function runGui()
chosenFile = '';
defScalingStr = {'2.0', '3.0', '4.0'};
function btnLoad_click(hObj, event)
[fileName, pathName] = uigetfile({ ...
'*.bmp; *.png', 'Image Files (*.bmp,*.png)'; ...
'*.*', 'All Files (*.*)'}, ...
'Select an image');
if ~isequal(fileName, 0)
chosenFile = fullfile(pathName, fileName);
end
end
function btnRun_click(hObj, event)
scaling = str2double(defScalingStr{get(lstScaling, 'Value')});
if isempty(scaling)
set(lstScaling, 'String', defScalingStr{1});
msgbox('Invalid scaling!');
return;
end
if ~exist(chosenFile, 'file')
msgbox('Please select an image.');
return;
end
set(btnRun, 'Enable', 'off');
onCleanup(@() set(btnRun, 'Enable', 'on'));
drawnow;
[interpolatedImg, rgbImg, highImg] = CDASR(chosenFile, scaling);
subplot(1, 3, 1);
imshow(interpolatedImg);
xlabel('Low resolution image');
subplot(1, 3, 2);
imshow(rgbImg);
xlabel('High resolution image');
subplot(1, 3, 3);
imshow(highImg);
xlabel('Original high resolution image');
end
fHandle = figure('Name', 'Deep Autoencoder', ...
'Visible', 'off', ...
'NumberTitle', 'off', ...
'Color', [0.9, 0.9, 0.9], ...
'OuterPosition', [100 100 1000 600]);
set(fHandle, 'MenuBar', 'none');
set(fHandle, 'ToolBar', 'none');
nGridX = 20;
nGridY = 12;
sizeScaling = [nGridX, nGridY, nGridX, nGridY];
txtScaling = uicontrol('Style','edit', ...
'String', 'Scaling', ...
'Enable', 'inactive', ...
'BackgroundColor', [0.9, 0.9, 0.9], ...
'Units', 'normalized', ...
'Position', [2.5, 10.5, 2, 1] ./ sizeScaling);
lstScaling = uicontrol('Style', 'popupmenu', ...
'String', defScalingStr, ...
'Units', 'normalized', ...
'Position', [5, 10.5, 2.5, 1] ./ sizeScaling);
btnLoad = uicontrol('Style', 'pushbutton', ...
'String', 'Select image', ...
'Units', 'normalized', ...
'Position', [10.5, 10.5, 3, 1] ./ sizeScaling, ...
'Callback', {@btnLoad_click});
btnRun = uicontrol('Style', 'pushbutton', ...
'String', 'Run SR', ...
'Units', 'normalized', ...
'Position', [14.5, 10.5, 3, 1] ./ sizeScaling, ...
'Callback', {@btnRun_click});
for ctrl = {txtScaling, lstScaling, btnLoad, btnRun}
c = ctrl{1};
set(c, 'FontSize', 10);
set(c, 'FontName', 'Segoe UI');
end
set(fHandle, 'Visible', 'on');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment