Loading, Processing and Analysing 3-D Images

Hello,
I have a volumetric 3-D binary Image (only one file in '.tiff') and would like to upload, display and process it in Matlab.
The Image solely contains black (0) and white (1) values - black is background and white pixels grouped together are some objects.
The main goal is to count all of the objects. I tried this using bwconncomp(), which apparently does not work. According to matlab, the total number of objects is 4. However, only the first slice of my 3-D image contains 4 objects and the whole 3-D image contains over a 100.
I loaded the 3-D image using imread(). How do I have to upload the image correctly so that I can see and count all objects in the 3-D space.
I would be very happy to receive a reply.
Thank you,
Anne

 采纳的回答

You say you have 4 objects in just the first slice and that there's at least 96 more in the remaining slices. Are you considering each slice to be one separate image? What if you have 20 slices and every single slice has those same blobs as the first slice. Do you have 4 objects, or 80 objects? bwconncomp() will say you have 4 because the objects in adjacent slices are connected to each other. What do you say?

8 个评论

Anne-Lene's "Answer" moved here.
Thank you very much for your quick answer. The whole 3D Image consists of 189 slices (= 2D images) and I consider my 3D image to be one image. I want to compute all objects (connected components) which lie in this 3D image. One object appears in approximately 5 adjacent slices and NOT in all 189 slices. So there are more then 4 objects. Does it make it clearer?
Thanks for an answer in advance.
Not really. bwconncomp should count correctly in 3D. Can you give proof it's not? Are you sure your objects are not touching, say at the corner or edge? Have you tried to adjust the connectivity? Try 6 instead of 26.
Anne-Lene's "Answer" again moved here because what she posted as an independent answer to her original question is actually not really an independent "Answer" to her original question, but actually a response to my comment above.
Ok, sorry and thanks. Yes I adjusted the connectivity before and it did not work. The objects are definitely not touching.
This is more or less how it looks like:
BW = imread('... .tif'); % read Image, one .tif file created from a stack of 2D .tif images
CC = bwconncomp(BW); % calculate objects as connected components
and NumObj is 4
Is that proof enough or should I give more/different information?
Thanks
Write out your BW as a .mat file and attach it so we can look at it.
Anne-Lene's "Answer" moved here:
Thank you a lot. I attached BW.mat, which contains - I guess - only the first slice. The whole image consist of 189 of those slices. Apparently, imread() does not load the whole '.. .tif' file. I created the file from a sequence of images using Fiji. What do you think? Thanks for your support!
There is no bw.mat attached. You said you had a 3D image, so why can't you just do this:
save('bw.mat', 'BW');
Why would it contain only the first slice instead of all 189 slices????
sorry, should be attached now.
OK, solved. The problem was how I used imread( .tif); reading all 2D images separately into a 4D matrix works. Thanks for the support.

请先登录,再进行评论。

更多回答(1 个)

Hi,
I have a similar problem but could not solve it. I used the following codes to reconstruct a 3D image that includes 2D slices
for slice = 1 : numberOfSlices filename = sprintf('image #%d', slice); fullFileName = fullfile(folder, filename); if exist(fullFileName, 'file) thisSlice = imread(fullFileName); array3d(:,:,slice) = thisSlice; end end
Then, I use imwrite and to obtain a tiff file that includes all 2D slices.
Now, I want to find connected components in the 3D tiff file. But, if I use
imread() function gives only the first slice in the tiff image.
Can you help me to solve this problem ?

1 个评论

You need to use the TIFF class if you want multi-page Tiff files. Otherwise you'll have to built up your 3D images slice by slice in 3D with a for loop
array3d = zeros(rows, columns, numSlices);
for slice = 1 : numSlices
thisImage = imread(......... % Read in this image file.
array3d(:,:,slice) = thisImage;
end

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by