How to create an undo button for image colorization?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm currently doing an image colorization application in GUI and I'm facing trouble in creating an undo button to undo the colours.
Can anyone help me with this?
Below is my code that might be useful for solving my problem.
Thank you.
function Result = Paint(InputImage,C)
Color(:,:,1)=C(1,1);
Color(:,:,2)=C(1,2);
Color(:,:,3)=C(1,3);
Color=uint8(Color);
Result=InputImage;
Level=graythresh(InputImage);
Img=im2bw(InputImage,Level);
[L,~]=bwlabel(Img);
[X,Y]=ginput(1);
Num=L(ceil(Y),ceil(X));
[R,C]=find(L==Num);
Tmp=[R,C];
for k=1:size(Tmp,1)
Result(Tmp(k,1),Tmp(k,2),1)=Color(:,:,1);
Result(Tmp(k,1),Tmp(k,2),2)=Color(:,:,2);
Result(Tmp(k,1),Tmp(k,2),3)=Color(:,:,3);
end
end
0 Kommentare
Antworten (1)
Jan
am 3 Mai 2019
An "Undo" button does not depend in any way from the applied computations. All you have to do is to store the formerly existing data in the GUI and restore it on demand. Now it matters, how you have created your GUI: With AppDesigner, GUIDE or programmatically? In all cases, create the wanted button and create a backup of the current values e.g. in the ApplicationData or UserData of the figure, before you call the function to modify the data.
See also this professional method: https://undocumentedmatlab.com/blog/customizing-uiundo
0 Kommentare
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!