Plotting 2D image with different slices in Multiple Figures by means of Loop
    7 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
For example I have a 3D image matrix but I want to plot it for some specific slices like following :
For 5 slices I want to draw 5 figures which will contain the 2D image of the specific slices and Intensity Profile (subplotting) and it should be plot through a LooP.  Any kinds of suggestion would be appreciated. 
Thanks in Advance !
i = 1:5; % Slice Number
RowProfile = squeeze(image3d(rowNumber, :, SliceNumber_total(i)));
img = image3d(:,:,SliceNumber_total(i));
0 commentaires
Réponses (1)
  Siraj
      
 le 15 Sep 2023
        Hi! It is my understanding that you want to create a subplot that displays multiple slices of a 3D image using a for loop.  
To understand how to achieve the desired result, please refer to the following code: 
% Create a 3D image with random pixel values ranging from 0 to 255 
image3d = randi([0 255], 1024, 1024, 5); 
% Iterate over each slice of the 3D image 
for i = 1:5 
    % Extract the current slice 
    img = image3d(:,:,i); 
    % Create a subplot with 1 row and 5 columns, and select the i-th subplot 
    subplot(1, 5, i) 
    slice_no = int2str(i);
    % Display the current slice using imshow 
    imshow(img); 
    title(slice_no);
end 
For displaying multiple images, there are various approaches available. You can refer to the following link that provides a detailed explanation of different methods. It will help you choose the one that best suits your task:  
Hope this helps. 
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


