crop images in ImageDatastore for semantic segmentation
2 次查看(过去 30 天)
显示 更早的评论
I have ImageDataStore and PixelDataStore objects related to a dataset of 200 labeled images. Since the resolution is large, I want to crop these images randomly (N number of crops) AND also crop the image at the center. The example provided by matlab
deals with one image at a time and not a whole dataset. How do I go about doing this? I figured I could randomly crop N images out of Image_1 and then concatenate them with the image cropped at the center. Say I choose N=11 randomly cropped images and 1 image cropped at the center.
When I do this, I obtain two TransformedDatastore objects. My question is, how do I concatenate them?
combine
does not work well or perhaps I am doing it wrong. After putting together the randomly cropped images and the center image for I_1 (total 12 images), how do I concatenate them with images resulting from I_2, I_3.... and so on?
I also read about
randomPatchExtractionDatastore
This would take care of the random crops of my original images, but how do I add the center cropped images to this object before training my network?
Should I just develop my own code, crop the images, save them to a folder and then read the folder with ImageDataStore and PixelDataStore?
0 个评论
采纳的回答
Sai Bhargav Avula
2020-5-12
Hi,
To the best of my knowledge this can be solved in multiple ways.
One possible work around is to used randomPatchExtractionDatastore to get the required number of random patches and augumentedImageDatastore or operate transform on imageDatastore. combine them and read them. This has a advantage of getting ordered images, meaning the centrecropped images and random cropped images are read simultaneously.
Since wanted to concatenate them you can try this
concatenatedDatastore = imageDatastore(cat(1,randomDatastore.Files,centerCroppedDatastore.Files));
This gives a single datastore of all the images you required to train.
Hope this helps!
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!