Images obtained by GAN could not be shown
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!