Borrar filtros
Borrar filtros

How do I control the output class of combine() with multiple image and trasnformedimage datastores?

2 visualizaciones (últimos 30 días)
I am trying to train an image to image regression network. I have a series of input and output images in different folders. I create seperate imagedatastore for each folder than use combine() to create the input for the network. When I use combine on the two datastores as long as one of them is a pure imageDataStore the output is a cell array as trainnetwork() expects, but if both imagedatastores are also transformed than the output becomes an array concating the two images.
Minimal reproducible code:
dataDir = fullfile(toolboxdir('vision'),'visiondata','triangleImages');
imageDir = fullfile(dataDir,'trainingImages');
imds = imageDatastore(imageDir);
targetSize = [224,224];
imdsTransformed = transform(imds,@(x) imresize(x,targetSize));
combinedDS1 = combine(imdsTransformed, imds);
combinedDS2 = combine(imdsTransformed, imdsTransformed);
response1 = preview(combinedDS1);
response2 = preview(combinedDS2);
whos response1
Name Size Bytes Class Attributes response1 1x2 51408 cell
whos response2
Name Size Bytes Class Attributes response2 8x448 3584 uint8
Given that the folders are dozens of gigabytes and I only want to transform the output image to do some proof of concept and parameter tuning exiperements, I don't want to save whole new batch of images to disk. Any way I can get combine() to concate two transformedDataStore and output a cell array?

Respuesta aceptada

Matt J
Matt J el 10 de Feb. de 2024
imdsTransformed = transform(imds,@(x) {imresize(x,targetSize)} );
  1 comentario
Christopher Greulich
Christopher Greulich el 12 de Feb. de 2024
Editada: Christopher Greulich el 12 de Feb. de 2024
Thanks! I can't believe I didn't try this. I tried, before submitting the question, using "cell()" instead of "{}" and was getting "Invalid Transform function defined on datastore.".
Glad it was this simple.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by