How to save image that show in axes?
Mostrar comentarios más antiguos
i have this code :
function mCube
load dtRegProp; % data of regionprops
load dtImBiner; % data binary image
dtPsgi = imBinerProp;
imBw = imBiner;
hMainGui = getappdata(0,'hMainGui');
hAxes2 = getappdata(hMainGui,'hAxes2');
axes(hAxes2);
% scale
imScale = imresize(imBw, size(imBw).*[1/2 1]);
% shear
shearMatrix = [1 0 0; -1 1 0; 0 0 1];
shearform = maketform('affine',shearMatrix);
imShear = imtransform(imScale,shearform);
% translation
sisi = mean([dtPsgi.MajorAxisLength,dtPsgi.MinorAxisLength]);
tx = 0;
ty = round(sisi);
transMatrix = [1 0 0; 0 1 0; tx ty 1];
transform = maketform('affine',transMatrix);
imTrans = imtransform(imShear,transform,'xData',[1 size(imScale,2)+ty], ...
'yData',[1 size(imScale,1)+ty]);
% find corner
sigma = 1;
radius = 1;
thresh = 0;
disp = 0;
[rShear,cShear] = harris(imShear,sigma,thresh,radius,disp);
[rTrans,cTrans] = harris(imTrans,sigma,thresh,radius,disp);
% change to real coordinate for display in axes2 in main gui
% 450 is size of an axes
rnShear = 450 - rShear;
rnTrans = 450 - rTrans;
% create line to make a cube, an final result is show in axes2 in
% main gui. In mLine function i use plot function to create line.
for i=1:3:4
hold on;
if mod(i,2) == 0
mLine(cTrans(i),rnTrans(i),cTrans(i-1),rnTrans(i-1));
mLine(cTrans(i),rnTrans(i),cTrans(i-2),rnTrans(i-2));
mLine(cShear(i),rnShear(i),cShear(i-1),rnShear(i-1));
mLine(cShear(i),rnShear(i),cShear(i-2),rnShear(i-2));
else
mLine(cTrans(i),rnTrans(i),cTrans(i+1),rnTrans(i+1));
mLine(cTrans(i),rnTrans(i),cTrans(i+2),rnTrans(i+2));
mLine(cShear(i),rnShear(i),cShear(i+1),rnShear(i+1));
mLine(cShear(i),rnShear(i),cShear(i+2),rnShear(i+2));
end
end
for i=1:4
mLine(cTrans(i),rnTrans(i),cShear(i),rnShear(i));
end
end
In main gui, there's a save button to save image that show in axes2. And i try this code in my save button..
hMainGui = getappdata(0,'hMainGui');
hAxes2 = getappdata(hMainGui,'hAxes2');
axes(hAxes2);
im = getappdata(0,'hImRes');
[fileName,pathName] = uiputfile('*.bmp','BMP Files(*.bmp)','Save as');
name = fullfile(pathName,fileName);
imwrite(img,name);
and my problem is in imwrite(img,name). How i can accommodate the calling function (mLine) in one variable and keep it? Or in other word, looping calling mLine function is to make cube and show in axes, how i can save the result??
Thx u
1 comentario
Cahaya
el 16 de Oct. de 2012
Respuestas (1)
Image Analyst
el 16 de Oct. de 2012
Editada: Image Analyst
el 16 de Oct. de 2012
0 votos
You can use saveas() to save the whole figure, or imwrite() to save just the image alone. But it doesn't look like you're getting the image, img. In your function, you never assign anything to img.
1 comentario
Cahaya
el 18 de Oct. de 2012
Categorías
Más información sobre Image Data en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!