필터 지우기
필터 지우기

How do i write a text..

조회 수: 2 (최근 30일)
George
George 2013년 6월 8일
I wrote this code and i would like to write a text on the top of this file and on the bottom. How can i do this?
grayImage = imread('moon.tif');
[height, width] = size(grayImage)
[X, Y] = meshgrid(1:width, 1:height);
numberOfPixels = length(X(:))
points = [X(:) Y(:) grayImage(:)];
A = [X(:) Y(:) grayimage(:)];
fid = fopen('moon.txt','wt');
for ii = 1:size(A,1)
fprintf(fid,'%g\t',A(ii,:));
fprintf(fid,'\n');
end
fclose(fid)

채택된 답변

Image Analyst
Image Analyst 2013년 6월 8일
편집: Image Analyst 2013년 6월 8일
Simply add a fprintf() before and after you write the gray levels to the text values.
fid = fopen('moon.txt','wt');
fprintf(fid,'Stuff at the beginning of the file.\n');
for ii = 1:size(A,1)
fprintf(fid,'%g\t',A(ii,:));
fprintf(fid,'\n');
end
fprintf(fid,'Stuff at the end of the file.\n');
fclose(fid)
  댓글 수: 5
Image Analyst
Image Analyst 2013년 6월 8일
Sorry - forgot to add that you need to pass in the file ID. See corrected code. If you don't have that it just prints to the command window.
George
George 2013년 6월 8일
thank you for your time!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by