Sort images in pixelLabelDatastore in serial order
3 ビュー (過去 30 日間)
古いコメントを表示
I was able to sort the images in imageDatastore in the right order using the natsortfiles function.
Please how do i do same for a pixelLabelDatastore. it's showing this error when i do same.
'Setting the Files property is not supported. Please create a new pixelLabelDatastore instead'.
X_test = imageDatastore(test_image,'IncludeSubfolders',true,'LabelSource','foldernames');
X_test.Files = natsortfiles(X_test.Files);
Y_test = pixelLabelDatastore(test_label,classNames,labelIDs,'IncludeSubfolders',true);
Y_test.Files = natsortfiles(Y_test.Files);
0 件のコメント
回答 (1 件)
Tushar
2023 年 2 月 21 日
Hi,
A pixelLabelDatastore stores files in lexicographical order. For example, if you have twelve files named 'file1.jpg', 'file2.jpg', … , 'file11.jpg', and 'file12.jpg', then the files are stored in this order:
'file1.jpg'
'file10.jpg'
'file11.jpg'
'file12.jpg'
'file2.jpg'
'file3.jpg'
...
'file9.jpg'
In contrast, an imageDatastore stores files in the order they are added to the datastore. If you simultaneously read a ground truth image and pixel label data, then you may encounter a mismatch between the images and the labels. If this occurs, then rename the pixel label files so that they have the correct order. For example, rename 'file1.jpg', … , 'file9.jpg' to 'file01.jpg', …, 'file09.jpg'.
Now, coming to the issue what you are facing, it is that setting the files property for imageDataStore is supported, while not supported yet for pixelLabelDatastore.
A possible workaround for your situation is to sort the values of pixelLabelDataStore into a separate variable or a new instance, and use it externally without changing the files property of the current pixelLabelDataStore instance.
You can try something like:
newVar = sort_nat(Y_test.Files);
% or newVar = natsortfiles(Y_test.Files);
% Now, you can use the sorted values correspondingly
Hope it helps!!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!