crop images in ImageDatastore for semantic segmentation

2 ビュー (過去 30 日間)
OJ27
OJ27 2020 年 4 月 21 日
回答済み: Sai Bhargav Avula 2020 年 5 月 12 日
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?

採用された回答

Sai Bhargav Avula
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 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by