필터 지우기
필터 지우기

How to image one text file from many

조회 수: 2 (최근 30일)
Dinos Layiotis
Dinos Layiotis 2022년 2월 9일
편집: Turlough Hughes 2022년 2월 10일
I have a set of text files consisting of depth values named '00.txt', '01.txt', '02.txt' etc, and I have imported them as shown below:
Images=dir(fullfile('folder1\folder2\','*.txt'));
ImageD = fullfile({Images.folder},{Images.name});
for i = 1:numel(ImageD)
dataImage(:,:,i)=importdata(ImageD{i}).data;
end
Now I would like to image only one of the files. How can I do that?
  댓글 수: 2
DGM
DGM 2022년 2월 9일
What do you mean "image a text file"? Are you trying to graph it?
Dinos Layiotis
Dinos Layiotis 2022년 2월 10일
Yes plot the surface of '00.txt' for example.

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

채택된 답변

Turlough Hughes
Turlough Hughes 2022년 2월 9일
You could use imagesc or imshow(___,[]) as follows:
dataImage = randi(1000,100,100,5); % example data you could have for dataImage
imagesc(dataImage(:,:,1))
Note, dataImage doesnt have the typical scale that an image does, which I expect is the case for you.
figure(), imshow(dataImage(:,:,1),[])
  댓글 수: 1
Turlough Hughes
Turlough Hughes 2022년 2월 10일
편집: Turlough Hughes 2022년 2월 10일
If it's a suface plot that you're looking for then you can use:
surf(dataImage(:,:,i))
To do a surface plot of each one (one figure each), you can write:
for ii = 1:size(dataImage,3)
figure()
surf(dataImage(:,:,ii))
end
Or you might prefer to use a tiledlayout:
N = size(dataImage,3);
m = ceil(N/3);
figure(), tiledlayout(m,ceil(N/m))
for ii = 1:size(dataImage,3)
nexttile
surf(dataImage(:,:,ii))
end

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

추가 답변 (1개)

yanqi liu
yanqi liu 2022년 2월 10일
Images=dir(fullfile('folder1\folder2\','*.txt'));
ImageD = fullfile({Images.folder},{Images.name});
for i = 1:numel(ImageD)
dataImage(:,:,i)=importdata(ImageD{i}).data;
end
for i = 1 : size(dataImage, 3)
figure; imshow(mat2gray(dataImage(:,:,i)));
end

Community Treasure Hunt

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

Start Hunting!

Translated by