We have a set of xray images im(x,y)
They are a 3D set in height im(x,y,h) through hte plane of an object.
The object is on a xray platfrom and the planes are between the source and detector.
I can make a movie going through the planes without a problelm.
However, I want to be able to see it as if i was looking from the side of the image set rather than the top but I keep getting errors
figure, imshow(image2(50,:,:))
Error using images.internal.imageDisplayValidateParams>validateCData (line 118)
Multi-plane image inputs must be RGB images of size MxNx3.
clear
path = ['C:\Users\\OneDrive - \Desktop\alabama concepts\image sets\3D images\ImageData-Reconstructed slices DICOM\mini1\mini1\0\']
y = VideoWriter("newfile4.mp4", 'MPEG-4');
y.FrameRate = 3
y.Quality=100
open(y)
for n = 2:24+1
file = ['mini1_mini1_0_', num2str(n) '.DCM'];
im = double(dicomread([path, file]))/2^16;
im = imcrop(im,[200,500,2700-200-400,1800-500]);
imshow(im);
m = n-1;
image2(:,:,m) = im;
hold on;
text(50, 50, ' Example - - Mouse', 'FontSize', 16, 'Color', 'white');
text(50, 100, 'sample - \0\mini1_mini\', 'FontSize', 16, 'Color', 'white');
text(50, 150, ['ZAxis: ', num2str(n-1), 'mm'], 'FontSize', 16, 'Color', 'white');
text(50, 200, ['Contact - no magnification '], 'FontSize', 16, 'Color', 'white');
text(50, 250, ['33kv 900uA'], 'FontSize', 16, 'Color', 'white');
F = getframe(gca);
im2 = frame2im(F);
writeVideo(y,im2);
end
close(y)

 Réponse acceptée

Cris LaPierre
Cris LaPierre le 20 Oct 2025
Modifié(e) : Cris LaPierre le 20 Oct 2025

0 votes

Try adding 'squeeze' to you code.
The image array you are passing to imshow is m x n x p. Even though m=1, because it is 3D, imshow is assuming it is rgb image data, which can only have a size of 3 in the 3rd dimension.
figure, imshow(squeeze(image2(50,:,:)))

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange

Produits

Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by