crop images in ImageDatastore for semantic segmentation

2 vues (au cours des 30 derniers jours)
OJ27
OJ27 le 21 Avr 2020
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?

Réponse acceptée

Sai Bhargav Avula
Sai Bhargav Avula le 12 Mai 2020
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!

Plus de réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by