Image displaying using GUI (User based choice)

Hello,
I am trying to create a code which can show or dipslays image, based on users choice so far I have created a code which runs and display image from desktop and shows it. I want to create a code using GUI which shows image from the list in a given folder from computer. I want the code to ask user to press 1 for this image and press 2 for another image or 3 to quit etc. How can I achieve this ?
Thanks
spec = imread('specs.jpg');
scene = imread('Image.jpg');
spec = rgb2gray(spec);
scene = rgb2gray(scene);
figure(1);
imshow(spec);
figure(2);
imshow(scene);
figure(3);
specPoints = detectSURFFeatures(spec);
scenePoints = detectSURFFeatures(scene);
[specFeatures, specPoints] = extractFeatures(spec, specPoints);
[sceneFeatures, scenePoints] = extractFeatures(scene, scenePoints);
matchPairs = matchFeatures(specFeatures, sceneFeatures);
matchedPoints = specPoints(matchPairs(:,1),:);
matchedsPoints = scenePoints(matchPairs(:,2),:);
[tform, inlierSpecPoints, inlierScenePoints] = ...
estimateGeometricTransform(matchedPoints, matchedsPoints,...
'affine');
Polygon = [1, 1;...
size(spec, 2), 1;...
size(spec, 2), size(spec, 1);...
1, size(spec, 1);...
1, 1];
newBoxPolygon = transformPointsForward(tform, Polygon);
imshow(scene);
%hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y')

답변 (2개)

Image Analyst
Image Analyst 2020년 5월 9일

0 개 추천

Try input:
usersNumber = input('Enter a number : ');
Image Analyst
Image Analyst 2020년 5월 9일

0 개 추천

Try this to make a list of all images in the folder on buttons. The user then clicks the button with the image name that he wants to use. Change the "folder" variable to whatever folder contains your images.
%===============================================================================
% Get the name of the demo image the user wants to use.
% Let's let the user select from a list of all the demo images that ship with the Image Processing Toolbox.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
% Demo images have extensions of TIF, PNG, and JPG. Get a list of all of them.
imageFiles = [dir(fullfile(folder,'*.TIF')); dir(fullfile(folder,'*.PNG')); dir(fullfile(folder,'*.jpg'))];
for k = 1 : length(imageFiles)
% fprintf('%d: %s\n', k, files(k).name);
[~, baseFileName, extension] = fileparts(imageFiles(k).name);
ca{k} = [baseFileName, extension];
end
% Sort the base file names alphabetically.
[ca, sortOrder] = sort(ca);
imageFiles = imageFiles(sortOrder);
button = menu('Use which demo image?', ca); % Display all image file names in a popup menu.
% Get the base filename.
baseFileName = imageFiles(button).name; % Assign the one on the button that they clicked on.
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);

댓글 수: 3

I will try this thanks.
Hey I wanted to allow my user to select an image from their end and get the desired output...how can I do that in MATLAB
@Samreen Shaikh the best way is to load a listbox with all the images in the folder of interest. I suggest you use MAGIC:
When you click on a filename in the listbox, it displays it.
Adapt it by changing the AnalyzeSingleImage() function to do the operations you want.
If it's not working, then post your changes to it.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB Coder에 대해 자세히 알아보기

질문:

2020년 5월 9일

댓글:

2022년 3월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by