Image Processing: DeInterleaving, is it possible?

3 visualizzazioni (ultimi 30 giorni)
Frank
Frank il 19 Mag 2011
Hello!
Is it possible for MatLab to "De-Interleave" stacked images? Originally this is a ImageJ plugin function, but it would be very useful it can be run through MatLab.
Thanks!
-Frank
Website
Diagram
  1 Commento
Frank
Frank il 19 Mag 2011
I'm aiming for getting images De-Interleaved and saved into a different folder through a loop function

Accedi per commentare.

Risposte (2)

Sean de Wolski
Sean de Wolski il 19 Mag 2011
Copied from Andrew with modifications:
function [A, B] = deinterleave(file_name)
I = imread(file_name); %don't call a variable image since it overwrites built-in function.
A = I(:,:,1:2:end);
B = I(:,:,2:2:end);
Not only is this vectorized but it can account for volumes with an odd number of pages (slices).
You could also change it to accept a 3D volume rather than a file name; I recommend that.
function [A, B] = deinterleave(I)
%I is a 3D volume
A = I(:,:,1:2:end);
B = I(:,:,2:2:end);
  13 Commenti
Frank
Frank il 19 Mag 2011
The function of deinterleaving organizes image stacks in the diagram above, it doesn't require the images to be in 3d, otherwise how was I able to deinterleave 2d images.
Thanks for the help though
Sean de Wolski
Sean de Wolski il 19 Mag 2011
Yes it does require them to be 3D. How can you pull the second slice from a 2d image? ImageJ may work differently and be able to read a file full of 2d images, but it's viewing that file internally as a 3D image.

Accedi per commentare.


Andrew Fowler
Andrew Fowler il 19 Mag 2011
This should be fairly straightforward if you are already working with a format that can be easily imported into matlab as an array. If you're working with a standard image format like .tif, or even dicom files, you should be able to set up an easy function with a quick for loop. Here's an example for a dicom file:
function [A, B] = deinterleave(dicom_filename)
image = dicomread(dicom_filename);
height = length(image(:,1,1));
width = length(image(1,:,1));
slices = length(image(1,1,:));
A = zeros(height, width, slices/2);
B = A;
for i = 1:length(image(1,1,:)
A(:,:,i) = image(:,:,(2*i-1));
B(:,:,i) = image(:,:,(2*i));
end
You can use IMREAD instead of DICOMREAD if you're using another format. If you're using a more esoteric image format like REC-PAR or 2dseq, you may need to do a little more work to actually import your images into matlab as arrays.
  3 Commenti
Andrew Fowler
Andrew Fowler il 19 Mag 2011
you should use IMREAD instead of DICOMREAD. Also Sean has some really good additions that you should probably follow. Ex:
i = imread('name.tif')
Frank
Frank il 19 Mag 2011
Thanks for the help

Accedi per commentare.

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by