imageDatastore for volumetric images
이전 댓글 표시
I want to use the imageDatastore command to prepare the training set for training a volumetric convolutional neural network-based semantic segmentation model. I followed the instructions given on the MATLAB webpage below and provided my code with multilayered Tif files representing the input images and the labled input images (ground truth).
However, it seems imageDatastore just reads one of the layers (slices) and cannot process the volumetric images. Does anyone know how we should use this command for the volumetric image segmentation tasks? Or how can we prepare the training set for training a volumetric sementic segmentation model such as Unet 3D (https://www.mathworks.com/help/vision/ref/unet3dlayers.html)? Many thanks in advance.
댓글 수: 2
NAVNEET NAYAN
2023년 2월 6일
Can you please provide the details of the images like how did you save these images and also about the lines of code that you are having a problem?
채택된 답변
추가 답변 (1개)
Aylin
2023년 2월 6일
0 개 추천
Hi Memo,
The blockedImage object (in Image Processing Toolbox) has documentation that mentions volumes within images:
A blockedImage object is an image made from discrete blocks. Use blocked images when an image or volume is too large to fit into memory. With a blocked image, you can perform processing without running out of memory.
There is an associated datastore which can be used to work with blockedImage called blockedImageDatastore.
Here is a list of examples which use blockedImageDatastore: https://www.mathworks.com/help/images/examples.html?category=large-image-files .
I hope this helps!
Rylan
댓글 수: 4
Ashish Uthama
2023년 2월 6일
If your data can fit into memory as an array, you can point blockedImage directly to it:
im= rand(10,10,10);
bim = blockedImage(im);
bimds = blockedImageDatastore(bim,'BlockSize',[2 2 2]);
b = read(bimds);
b{1}
ans(:,:,1) =
0.8147 0.1576
0.9058 0.9706
ans(:,:,2) =
0.1622 0.4505
0.7943 0.0838
Backing up though, maybe you could add more information for the full workflow. You mention: "I converted the images to a volume tif file using a MATLAB" What was the original source? What is the 'unit' of training data you want to use? (one block from a volume, or the full volume?).
To train, you need a datastore where one unit/read of that gives you one unit of data you want to train. You can use imageDatastore with a custom read function and use tiffreadvolume to read in one volume at a time. If these volumes are too big, and you want to train on blocks extracted from it - then consider using blockedImageDatastore (you'll like have to write a custom adapter to handle volume file like you are using, post back and I can help with that if its something you want to try).
For labels, training expects labels to be in a datatype called categorical: https://www.mathworks.com/help/matlab/categorical-arrays.html . Are you labels in uint8? Once you create a datastore, you can use a transform call to convert uint8 to categorical labels.
This might seem like a lot - but should hopefully make more sense once its all put together.
Memo Remo
2023년 2월 6일
카테고리
도움말 센터 및 File Exchange에서 Blocked Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!