필터 지우기
필터 지우기

Plotting 2D image with different slices in Multiple Figures by means of Loop

조회 수: 3 (최근 30일)
Amit Chakraborty
Amit Chakraborty 2022년 7월 13일
답변: Siraj 2023년 9월 15일
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));

답변 (1개)

Siraj
Siraj 2023년 9월 15일
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.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by