Read 4 Rotated Images from image datastore
3 次查看(过去 30 天)
显示 更早的评论
I need to train a CNN using rotated images and their labels. In my image set (about 10,000 images of the same size), I rotate each image at 0, 90, 180 and 270 degrees, and label the rotated images with 0, 1, 2 and 3 respectively. The rotated images are stores in the sub-folders of names "0", "1", "2" and "3". To train the CNN, I want to feed the CNN model with 4 rotated images of the SAME image. For example, if the original image is image1, I want to get image1_0 (i.e. image1 rotated at 0 degree), image1_1 (i,e. image1 rotated 90 degrees), image1_2 (image1 rotated 180 degrees) and image1_3 (image1 rotated 270 degrees) to send them to the CNN, not randomly choosing four images from the image datastore. I'd appreciate any guidance about how to proceed.
2 个评论
yanqi liu
2022-3-1
yes,sir
if input image1_0 (i.e. image1 rotated at 0 degree), image1_1 (i,e. image1 rotated 90 degrees), image1_2 (image1 rotated 180 degrees) and image1_3 (image1 rotated 270 degrees)
now get 28*28*4 matrix
what is output? is it 1?
回答(1 个)
Image Analyst
2022-3-1
You can use the augmenter to create and rotate images on the fly. You don't need to create and save them to disk in advance.
2 个评论
Image Analyst
2022-3-1
imrotate, which the augmenter probably uses, is higly optimized. I'd bet that if the rotations are an integer multiple of 90 there is a special case to not do the full general math and just do the simplified operations like flip and transpose.
The augmenter takes an image data store and a label data store. So whatever operations are done by the augmenter are also done to the corresponding labeled image. For example if the original image is translated by 10 pixels and rotated by 30 degrees, the label image is also translated by 10 pixels and rotated by 30 degrees. Obviously it has to be this way ortherwise augmentation would not work.
I'm not sure why you want to "control" the images that are fed into the CNN. Yes it extracts some specified number of images into a minibatch randomly to speed up training. I don't know why this would be a problem. Why do you want to control which images are put into each minibatch? In the end all the images get used for training anyway.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!