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

6 Ansichten (letzte 30 Tage)
I tried a loop but it did not work:
for i = 1:size(df,3)
  3 Kommentare
BA am 8 Aug. 2022
Bearbeitet: BA am 8 Aug. 2022
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 8 Aug. 2022
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_, ', ')) ;
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+";")
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 Kommentare
BA am 8 Aug. 2022
I used concatenate and it works :)
df =cat(3,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)

Melden Sie sich an, um zu kommentieren.


Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by