How to concatenate/combine a list of images in one mat.file (convert picture 1 into picture 2)

조회 수: 3 (최근 30일)
I tried a loop but it did not work:
for i = 1:size(df,3)
imshow(df(:,:,i))
end
  댓글 수: 3
BA
BA 2022년 8월 8일
편집: BA 2022년 8월 8일
wow, thank you for this explanation. Picture 2 (someone's file) is a list of images so when I do 'imshow(dff(:,:,1))' it returns the first image but when I tried to do similar to my list of images it gives me an error. I think I need a way to make the images as 417x600x30, so the issues how to stack the 10 pages together as an array.
Yes, I am after number 2, the images are ultrasound (black and white) see attached as an example.

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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 8월 8일
What you are asking for is possible but not recommended. You are asking to open the variable browser on each field of the struct, and have the header be the same as the field name. In order to do that it is necessary to extract the fields from the structure into individual variables that have the same name as the field names, as the command to open the variable browser only supports plain variable names, not field references.
The below code does that extraction, but first it makes sure that doing so would not overwrite any variable of the same name.
The code cannot be put into a function because any variable created would disappear as soon as the function returned. (Unless perhaps something could be done around global variables or persistent variables or base workspace.)
The code should be improved to check for conflicts with the variable names used to manage the loop. Oddly, that part could be put into a function.
F_E_I_L_D_S = fieldnames(df);
K_N_O_W_N = whos();
B_O_T_H_ = F_E_I_L_D_S(ismember(F_E_I_L_D_S, K_N_O_W_N));
if ~isempty(B_O_T_H_)
error('cannot view fields without interfering with existing variables: %s', strjoin(B_O_T_H_, ', ')) ;
end
for I_N_D_X_ = 1 : length(F_E_I_L_D_S)
T_H_I_S_ = F_E_I_L_D_S{I_N_D_X_};
eval( T_H_I_S_ + "= df."+T_H_I_S+";")
openvar(T_H_I_S_)
end
Creating variable names dynamically is seldom a good idea.
Note that the variable browser will allow you to edit the values, but the changes will not be written back to the struct.
  댓글 수: 3
BA
BA 2022년 8월 8일
편집: BA 2022년 8월 8일
Thank you for this. Picture 2 (someone's file) is a list of images so when I do 'imshow(dff(:,:,1))' it returns the first image but when I tried to do similar to my list of images it gives me an error. I think I need a way to make the images as 417x600x30, so the issues how to stack the 10 pages together as an array.
I tried you codes but I have the following error:
Error using cell/ismember (line 34)
Input A of class cell and input B of class struct must be cell arrays of character vectors, unless one is a
character vector.
BA
BA 2022년 8월 8일
I used concatenate and it works :)
df =cat(3,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by