Clear Filters
Clear Filters

How to create a session for images using matlab 2013a

1 view (last 30 days)
Sir, I need a help regarding how to store images using matlab 2013a. In my page, I'm going to select images and I cropped that images and I stored those images in a folder for one user. In my case , I can crop images and successfully store images in a folder but when multiple users login and crop their images and stored it. Please help me about how can store images for different users while logging in.
  2 Comments
Adam
Adam on 16 Mar 2017
Don't your users just select a folder to save to as with most windows applications that allow saving?
Maruthi Maruthi
Maruthi Maruthi on 17 Mar 2017
My page having cropped images and these images maintains a separate folder for each user. How can I place cropped images separately for each user... Please help me... This is required for my project...

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 16 Mar 2017
This just seems to be a question of good programming design, best done in advance. Think about the needs for your code. If one such need is that each user has their own special place, then when they access the tool, you have them indicate where that will be. If they need to "login" to use this gui, then that tells you who the user is.
Probably easiest is to just define a database of users, which you could store in a .mat file. It would include any such information about where they wanted files stored. Then just update that file as necessary.
Or, you could probably store any user specific information using the preferences tools in MATLAB.
help setpref
help getpref

Walter Roberson
Walter Roberson on 17 Mar 2017
function name = whoami
if ispc()
name = getenv('USERNAME');
else
name = getenv('USER') ;
end
You can now use the returned string as the folder name within some constant project folder. Watch out as you will want new users to be able to create the appropriate folder at need, which requires that everyone has write access to the project folder. But then that is a risk because people could potentially remove other people's work.
More common would be to save the files in a directory owned by the user. On pc you can use the Windows environment variables to figure out an appropriate location; on osx or Linux you can use the HOME environment variable.
Or you could use uigetdir() to allow the user to indicate which directory they want to use.
  1 Comment
Maruthi Maruthi
Maruthi Maruthi on 18 Mar 2017
In the above code, I used code for cropped images for single user. I want this code for many users and maintain cropped images separately for each user but how? Please give me the code for that and am applying this code for login phase. At the registration phase, the login phase, user has to select images among the set and cropped that particular images as many times as he want and store images in a folder . while at the login phase, he has to select same cropped images that should match with already cropped images. Please help me for that... Sir, please help me regarding that.......... function ImagesExample() %# read images in a cell array imgs = cell(6,1); for i=1:6 imgs{i} = imread( sprintf('C:/Users/maruthi1/Documents/MATLAB/images3/ma3%1d.jpg',i) ); end
%# show them in subplots
figure(1)
for i=1:6
subplot(2,3,i);
h = imshow(imgs{i}, 'InitialMag',200, 'Border','tight');
title(num2str(i))
set(h, 'ButtonDownFcn',{@callback,i})
end
function callback(o,e,idx)
%# show selected image in a new figure
figure(2), imshow(imgs{idx})
title(num2str(idx))
promptMessage = sprintf('Drag out a box that you want to copy,\nor Cancel to abort processing?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return;
end
A=imgs{idx};
n = input('Please enter the number of scenes you wish to crop: ')
ii=1;
%im_cropped = imcrop(A);
%B=imgs{idx};
%im_cropped = imcrop(B);
%C=imgs{idx};
while (ii<4)
%[im_cropped rect] = imcrop(A);
im_cropped{ii} = imcrop(imgs{idx});
filename = ['images3\images_cropped\trial' num2str(ii) '.jpg'];
imwrite(im_cropped{ii},filename);
ii=ii+1; end promptMessage = sprintf('Your cropped images saved successfully'); titleBarCaption = 'Continue?'; button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue'); if strcmpi(button, 'Cancel') return; end end %croping(A); end

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!