How to make image labeler pixel label output file name same as the imput file name?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a folder contained images with file names 1, 2, 3...png. After labelling using image labeler app in image processing toolbox I am expecting the image pixel label to have same file names as the original image but stored in a separate folder.
Presently the label files are having file names as label_1_1.png. This is causing issues with image-label correspondence while training CNN models because sort order of image files and labels files is not coming same. Is it possible for matlab to output labels with same file name as the original image?
댓글 수: 0
채택된 답변
Shlok
2024년 7월 12일
편집: Shlok
2024년 7월 12일
Hi,
I understand that you want the image pixel label files to have the same name as the original image files.
The PNG files within the output folder (“PixelLabelData”, for example) are typically stored using a specific naming convention. This naming convention usually follows the format "Label_<X>_<ImageName>.png", where "X" represents a number associated with the sequence in which the image was imported in the Image Labeler App.
This is a default behaviour, and hence we need a workaround to achieve the custom output filename. The logic is to run an additional script to remove the prefix “Label_<X>_” from each file name present in the “PixelLabelData" folder.
% Define the folder where the exported pixel label files are located
folderPath = 'Your_Path_To_Pixel_Label_Data';
% Get a list of all files in the folder
fileList = dir(fullfile(folderPath, '*.png'));
% Loop through each file in the folder
for k = 1:length(fileList)
% Get the current file name
oldFileName = fileList(k).name;
% Use regular expression to remove the prefix "Label_<X>_"
newFileName = regexprep(oldFileName, '^Label_\d+_', '');
% Rename the file
oldFilePath = fullfile(folderPath, oldFileName);
newFilePath = fullfile(folderPath, newFileName);
movefile(oldFilePath, newFilePath);
end
You can refer to the following documentation link to learn more about Pixel Label Data Storage:
Hope this helps.
Regards,
Shlok
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
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!