Getframe function problem: Captured Image will not re-display at same size
Mostrar comentarios más antiguos
goal: I want to be able to capture the color by pixel location data (C-data?) of any current figure, scramble the locations of any black pixels in it, and then re-display the figure in scrambled form.
problem: After scrambling the figure and re-displaying it, it is now a different size than the old figure. I want it to be the same size as the unscrambled version.
I think the problem lies in how I am capturing and then displaying the image. This is how I am doing that: (after creating a current figure). Attached is a screenshot of the problem for clarity. I am running 2015a.
function[CurrentFigureData, CurrentFigureMap]= WriteCF2Workspace()
F = getframe(gcf);
[CurrentFigureData, CurrentFigureMap] = frame2im(F);
end
figure(2);ScreenDims = get(0, 'ScreenSize'); set(2,'position',ScreenDims, 'menubar','none'); image(CurrentFigureData); axis off;
2 comentarios
Image Analyst
el 3 de Oct. de 2015
Why not just use an axes control with an image in it, instead of trying to do the whole figure?
Michael Bronstein
el 3 de Oct. de 2015
Respuestas (2)
Walter Roberson
el 3 de Oct. de 2015
curfig = gcf;
curfig_units = get(curfig, 'units');
curfig_size = get(curfig, 'Position');
curimage_h = findall(curfig, 'type', image');
curax = ancestor(curimage_h, 'axes');
fig2 = figure('Units', curfig_units, 'Position', curfig_size);
ax2 = copyobj(curfig_ax, fig2);
image2 = copyobj(curimage_h, ax2);
7 comentarios
Michael Bronstein
el 3 de Oct. de 2015
Walter Roberson
el 4 de Oct. de 2015
curfig = gcf;
curfig_units = get(curfig, 'units');
curfig_size = get(curfig, 'Position');
curimage_h = findall(curfig, 'type', image');
curax = ancestor(curimage_h, 'axes');
fig2 = figure('Units', curfig_units, 'Position', curfig_size);
ax2 = copyobj(curax, fig2);
image2 = copyobj(curimage_h, ax2);
Michael Bronstein
el 4 de Oct. de 2015
yuval
el 8 de Ag. de 2018
Hi Michael, I'm facing similar difficulty, were you able to figure it out?
Michael Bronstein
el 8 de Ag. de 2018
Michael Bronstein
el 8 de Ag. de 2018
Michael Bronstein
el 8 de Ag. de 2018
yuval
el 8 de Ag. de 2018
0 votos
Replace gcf with gca, i.e.,
F = getframe(gca); [CurrentFigureData, CurrentFigureMap] = frame2im(F);
Categorías
Más información sobre Image Arithmetic 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!