Skip to content

Instantly share code, notes, and snippets.

@summivox
Last active October 30, 2015 14:06
Show Gist options
  • Save summivox/749b59b2770b83f87e91 to your computer and use it in GitHub Desktop.
Save summivox/749b59b2770b83f87e91 to your computer and use it in GitHub Desktop.
MatLab trick: read-plot-write an image
img = imread('in.png');
f = figure('visible', 'off');
imshow(img, 'Border', 'tight');
hold on;
rectangle('Position', [100, 200, 300, 150], 'EdgeColor', 'y');
hold off;
F = getframe(gcf);
imwrite(F.cdata, 'out.png');
close(f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment