How do i adjust the spacing between the slices of my stacked images?
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, i want to adjust the spacing between the slices of images i load in with "cat". Right now, they are stacked from 1 to 4, but how do i achieve that they are stacked not in steps of 1 but e.g. of 4?
What i did so far is this:
IA = imread('/Users/Desktop/Testdateien/1.tif')
IB = imread('/Users/Desktop/Testdateien/2.tif')
IC = imread('/Users/Desktop/Testdateien/3.tif');
ID = imread('/Users/Desktop/Testdateien/4.tif')
rgb4D = cat(4, IA, IB, IC, ID);
[D, map] = gray2ind(rgb4D);
I think i have to do sth. with the D matrix, but i don't know what.
Can anybody please help? Thanks in advance.
댓글 수: 0
답변 (2개)
Walter Roberson
2016년 10월 25일
gray2ind does not apply to stacked images. You would have to do that and then stack the results. You would need to pass the rgb or gray table to gray2ind so that you got the same meaning of ind in each case.
To stack with layers of zeros, construct a layer of zeros of the appropriate size and stack it in.
spacing = 4;
Z = zeros([size(IA), spacing-1], class(IA)) ;
cat(4, Z, IA, Z, IB, Z, IC, Z, ID)
댓글 수: 4
Walter Roberson
2016년 10월 28일
If you are looking at the example https://www.mathworks.com/help/images/examples/exploring-slices-from-a-3-dimensional-mri-data-set.html then in step 3 where they talk about
"We create a tform via composition starting with a 2-D affine transformation T1 that scales the (new) dimension 1 by a factor of -2.5 and adds a shift of 68.5 to keep the array coordinates positive"
then the -2.5 corresponds to the pixel spacing. So you would alter
T1 = maketform('affine',[-2.5 0; 0 1; 68.5 0]);
to reflect the spacing you want, and then you would put the result through the resampler.
Massimo Zanetti
2016년 10월 25일
First, most probably you don't want to stack them in the 4-th dimension as you wrote
rgb4D = cat(4, IA, IB, IC, ID);
Because this is not RGB image. If I have to guess what you are trying to do, I come with this:
IA = imread('/Users/Desktop/Testdateien/1.tif')
IB = imread('/Users/Desktop/Testdateien/2.tif')
IC = imread('/Users/Desktop/Testdateien/3.tif');
ID = imread('/Users/Desktop/Testdateien/4.tif')
rgb4D = cat(3, IA, IB, IC, ID); %notice the 3 instead of 4
%if IA,...,ID are single band images, to stack them with spacing of 4
STACKED4 = zeros([size(IA),13]);
STACKED4(:,:,1:4:13) = rgb4D
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!