How to reorganization all image long z axis

Dear all, I have a question and would like to seek your help. There are beam signals. I took several 2D images (x,y) along the z axis, and I would like to reorganise all images along the z axis. Could you please give me some help? (a few images has attached) I would like to combine with 1.5.bmp, 2.0.bmp, 2.5.bmp along the z-axis . Thank you very much : )

4 Comments

What do you mean by reorganise? You want to plot them?
yes! I would like to plot them along z axis.
x and y data is from image, z data is from file name. For example: z= 1.5 mm, the x,y data from the image 1.5.bmp ; z = 2.0mm. the x1,y1, data from the image 2.0.bmp, etc...
slice and sliceViewer may also come in handy, although they don't produce the results you're describing above.

Sign in to comment.

 Accepted Answer

files = dir('*.bmp');
full_file_names = fullfile({files.folder},{files.name});
[~,fn,~] = fileparts(full_file_names);
z = str2double(fn);
figure
hold on
for ii = 1:numel(files)
[I,map] = imread(full_file_names{ii});
warp(z(ii)*ones(size(I)),I,map);
end
xlabel('x')
ylabel('y')
zlabel('z')

6 Comments

Thank you for the help, but I am sorry, I still can not plot the figure successfully. My code is below, thanks for helping me again.
clear all; close all; clc
D= '/Users/Tina/Desktop/2022.06.30';
S= dir(fullfile(D,'*.bmp'));
% files = dir('*.bmp');
full_file_names = fullfile({files.folder},{files.name});
[~,fn,~] = fileparts(full_file_names);
z = str2double(fn)
figure
hold on
for ii = 1:numel(files)
[I,map] = imread(full_file_names{ii});
warp(z(ii)*ones(size(I)),I,map);
end
xlabel('x')
ylabel('y')
zlabel('z')
The variable returned from dir is called files in my example, not S:
clear all; close all; clc
D= '/Users/Tina/Desktop/2022.06.30';
% S= dir(fullfile(D,'*.bmp'));
files = dir(fullfile(D,'*.bmp'));
full_file_names = fullfile({files.folder},{files.name});
[~,fn,~] = fileparts(full_file_names);
z = str2double(fn)
figure
hold on
for ii = 1:numel(files)
[I,map] = imread(full_file_names{ii});
warp(z(ii)*ones(size(I)),I,map);
end
xlabel('x')
ylabel('y')
zlabel('z')
I am sorry again! I follow your suggestion, but I still get error which shows as below, could you please help me again? Thanks a lot. My matlab version is R2017a
Error using fileparts (line 32)
Input must be a row vector of characters.
OK, try this:
clear all; close all; clc
D= '/Users/Tina/Desktop/2022.06.30';
files = dir(fullfile(D,'*.bmp'))
figure
hold on
for ii = 1:numel(files)
full_file_name = fullfile(D,files(ii).name);
[~,fn,~] = fileparts(full_file_name);
z = str2double(fn);
[I,map] = imread(full_file_name);
warp(z*ones(size(I)),I,map);
end
xlabel('x')
ylabel('y')
zlabel('z')
Thank you very much for your help. It works well : )
You're welcome! I'm glad it's working!

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2017a

Asked:

on 1 Jul 2022

Commented:

on 13 Jul 2022

Community Treasure Hunt

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

Start Hunting!