Images obtained by GAN could not be shown

1 回表示 (過去 30 日間)
S C.Carl
S C.Carl 2022 年 6 月 14 日
編集済み: S C.Carl 2022 年 6 月 15 日
Hi,
I run the codes at https://www.mathworks.com/help/deeplearning/ug/train-generative-adversarial-network.html which generates 25 new images and shows the generated images after tiling and scaling by this;
I = imtile(extractdata( dlXGeneratedNew ));
I = rescale(I);
But, I want to show each generated image (separately) without tiling and scaling, and to put them into the array called Images(224,224,3,25). So, I have written this;
rows = 5; columns=5; ind=1;
% Get size of 1
row1 = rows/5;
col1 = columns/5;
for col = 1 : 5
leftCol = (col-1) * col1 + 1;
rightCol = leftCol + col1 - 1;
for row = 1 : 5
topRow = (row-1) * row1 + 1;
bottomRow = topRow + row1 - 1;
thisImage = I(topRow:bottomRow, leftCol:rightCol, :);
figure(ind); imshow(thisImage);
Images(:,:,:,ind) = thisImage;
ind = ind + 1;
end
end
Here, thisImage returns as 1x1x3 single array. So, its size and format is different from an input image, which is 224x224x3 uint8.
Could you please help me to solve this problem

回答 (1 件)

Hiro Yoshino
Hiro Yoshino 2022 年 6 月 15 日
I belive the lines
I = imtile(extractdata( dlXGeneratedNew ));
I = rescale(I);
are not behaving as you would expect.
The function imtile accepts multiple files and put them into a small image. So you should remove it as follows:
I = extractdata( dlXGeneratedNew );
img = I (:,:,:,idx)
igm = rescale(img);
where idx represent the index of the image of your interest.
  1 件のコメント
S C.Carl
S C.Carl 2022 年 6 月 15 日
編集済み: S C.Carl 2022 年 6 月 15 日
Thank you Hiro.
I have one more question: The GAN example generates 25 images and uses 5 classes of flower images.
I want to generate 1260 images and to use 7 classes (each class includes 60 images, so there are 7x60=420 orijinal images. I want to generate 3 times of the orijinal images, i.e., 3x420 = 1260)
So, running the GAN example 50 time to generate about 1260 images means construction the GAN 50 times for each running, which will be time consuming.
So, should I run the GAN example by changing only these? :
numValidationImages = 49; % instead of 25;
numObservations = 1260; % instead of 25;
To be able to generate equal number of images from each class, should be the following codes updated or not?
ZValidation = randn(numLatentInputs,numValidationImages,'single');
Z = randn(numLatentInputs,miniBatchSize,'single');
ZNew = randn(numLatentInputs,numObservations,'single');

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by