How to write each slices from volume in MATLAB into jpg format?

조회 수: 2 (최근 30일)
Javaid Iqbal
Javaid Iqbal 2018년 3월 24일
댓글: Image Analyst 2021년 6월 10일
Hello dear may you please help for solving a problem: I have 3D Volume dataset in .niit format I read this data in MATLAB and also can show each slice from this volume....but I'm unable to write each slice in jpg /2D form How we can write each slice from volume by using imwrite in MATLAB?

채택된 답변

Image Analyst
Image Analyst 2018년 3월 24일
편집: Image Analyst 2020년 6월 22일
You probably don't want to do that anyway, unless you use lossless jpeg2000 format. Use PNG for lossless compression
for sliceIndex = 1 : size(image3d, 3)
thisSlice = image3d(:,:,sliceIndex);
filename = sprintf('Slice #%d.png', sliceIndex);
imwrite(thisSlice, filename);
end
image3d is your 3-D image array.
  댓글 수: 5
Meriem YOUss
Meriem YOUss 2021년 6월 10일
how to do the same code with a set of images with a loop, and save only the first slice of each image?
Image Analyst
Image Analyst 2021년 6월 10일
@Meriem YOUss, put the code above into a loop over all files, which you can get code for in the FAQ: https://matlab.fandom.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by