How to I write modified image data to a new file?
Show older comments
I am close. This is a code snippet that I modified from this website:
% load the image and put it in a figure
A = imread('test.tif');
imagesc(A)
% adding some text to the figure
text(200,100,'This is only test')
% Now I want to write the ANNOTATED image to a new file
h = gcf;
axesObjs = get(h,'Children');
dataObjs = get(axesObjs,'Children');
objTypes = get(dataObjs,'Type');
zdata = get(dataObjs(2),'CData');
imwrite(zdata,'testnew.tif');
The above all works, but I want to combine the text information (?dataObjs(1)?) with the new image that I write in the last statement. Basically, when I imread the new image file, I'd like it to be the annotated version. Can anyone tell me where to go next?
Thanks for the help.
Answers (1)
Geoff Hayes
on 28 May 2014
0 votes
A similar question was asked at add text to image. It involves creating an image of just the text only and then adding that information (in this case, the white pixels that correspond to the text) to the original image. Worked well.
Categories
Find more on Convert Image Type 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!