how to restore deleted frame

i have a folder of images... i wrote a code to delete an image from it and restore the deleted image....i display the folder of images in a listbox and on select of a particular item from listbox i delete that image from the folder and listbox.... but if i delete more than one image only the last image i deleted is getting restored... can anyone help me with the code....

 Accepted Answer

Image Analyst
Image Analyst on 22 Dec 2012
I think you're best off just reloading the listbox from the directory listing instead of trying to micromanage the old listbox string. Regardless, I don't see where you're restoring any items to the listbox. You delete an item(s) but never stick any back it, at least not in the code you showed.

8 Comments

no sir i restore the item in
variable = curstrings{curidx};
restore=variable;
and then use it in ....
figure,imshow(fullfile( 'imageFolder', restore ));
title('THE RESTORED IMAGE');
but when i delete more than one frame only last frame is getting restored....
Nowhere in the code do you ever change curstrings. What is the purpose of curstrings and what does it get set to, and where does it get set?
if curstrings is to act as a "stack" of the names of removed images, then when you remove an image you need to add it to the stack and you need to update curidx; likewise when you restore, you need to change curidx to indicate the previous saved image.
Elysi Cochin
Elysi Cochin on 26 Dec 2012
Edited: Elysi Cochin on 26 Dec 2012
sir if the code i wrote is wrong please do correct it for me... i just tried from various help sources available from the net.... please show me how to do it....
When you remove an image,
curidx = curidx + 1; curstrings{curidx} = filepath;
When you are asked to restore the last image, you can find the filename it should go to as curstrings{curidx} . After you have restored it, curidx = curidx - 1;
Now you have to decide: when you "delete" an image, where to you want to store the copy of the image to restore it from? And keep in mind that if you keep all the deleted images in memory that that could add up to a lot of space if you are working with large images.
Elysi Cochin
Elysi Cochin on 26 Dec 2012
Edited: Elysi Cochin on 26 Dec 2012
sir i need to restore all deleted images... not the last deleted image alone.... whatever image i delete i shud be able to restore it sir....
That's fine, but you need to decide how you want to store the content of the "deleted" images. I am assuming, of course, that the images contain indecency so you cannot use the usual trick of uploading them as a youtube video.
I don't know what restore means either. Have you seen this in the help:
By default, the delete function permanently deletes files. To move them to a different location instead, use the Deleting files preference:
1.
On the Home tab, in the Environment section, click Preferences > General.
2.
Set the Deleting files option you want.
Setting the preference to delete files permanently makes delete run faster.
To override the preference when using the delete function, use the recycle function.
So if you want to restore a function, you'll most likely need the movefile() function to restore it out of the recycle bin, but you'll first need to use the recycle() function rather than the delete() function.

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!