MATLAB Answers

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

14 views (last 30 days)
Javaid Iqbal
Javaid Iqbal on 24 Mar 2018
Edited: Javaid Iqbal on 24 Mar 2018
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?

  0 Comments

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 24 Mar 2018
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);
write(thisSlice, filename);
end
image3d is your 3-D image array.

  2 Comments

Javaid Iqbal
Javaid Iqbal on 24 Mar 2018
Still showing this error: Undefined function 'write' for input arguments of type 'int16'. Error in test (line 5) int16(write(thisSlice, filename));
Javaid Iqbal
Javaid Iqbal on 24 Mar 2018
@ Image Analyst Please see this file attached here I want to read each slice from these volume an dthen want to write each slice in .png or jpeg format. I try this given code but showing error still. please help me for this problem Thansk

Sign in to comment.

More Answers (0)

Sign in to answer this question.